Stop dogs from digging by first determining why they are digging; different causes require different solutions. Dogs that dig for entertainment purposes require ways to amuse themselves and tire themselves out when left outside. Dogs that dig to catch prey, like small animals or insects, stop once the pests are taken care of. Dogs that dig for comfort or protection from inclement weather require a comfortable shelter to stop digging.
Some dogs that dig do so because they require extra attention, which is easy to fix by providing extra attention throughout the day. Some dogs use digging as a way to escape from the yard. Prevent escape digging by burying chicken wire at the base of the fence and partially burying large rocks around the perimeter of the fence. Extending the fence 1 to 2 feet below the surface and anchoring chain-link fencing to the bottom of the regular fencing also helps prevent escape digging.
For dogs that dig for entertainment, incorporate at least two walks into their routines every day. Redirect their energy by teaching them to play fetch and teaching them some basic commands or tricks. Keeping a variety of toys in the yard for dogs to play with when they get bored also prevents digging. Make sure to keep sets of toys in rotation to keep the dog's interest.