Question: how to train dog not to leave yard?
Answer: Ask a friend to run quickly across your yard crossing the property line. If your dog doesn't chase, offer him a treat. If he does try to follow, stop or shorten the leash to keep him on the correct side. You can also use the 'leave it' command.