The first step to stopping your dog from digging is to identify the cause. Are they digging to escape, bury something, or simply out of boredom? Once you know the cause, you can start to address the problem.
If you can't remove the temptation, provide your dog with an alternative. For example, if they are digging to escape, give them a designated area in the yard where they are allowed to dig.
If you catch your dog digging, redirect their attention to something else, such as a toy or game. You can also try using a command such as "leave it" to discourage them from digging.
The most important thing is to be consistent with your training. If you allow your dog to dig sometimes, they will learn that it is okay to do.
When your dog does not dig, reward them with praise or a treat. This will help them to learn that not digging is a good thing.
Punishing your dog for digging is not likely to be effective. It may actually make the problem worse.
If you have tried all of the above and your dog is still digging, it is possible that there is an underlying medical condition. Take your dog to the vet to rule out any medical problems.