Just as a child will mimic a parent, dogs will mimic people. If you are a gardener, the dog will dig to mimic human behavior.
Don't dig within sight of the dog. Put the dog away in the house or garage when you garden.
Digging in the shade
In shade areas, even if the area is only shaded part of the time, the dog is trying to stay cool.
Get a child's pool and put a little water in it. The dog can lay in the pool to get cool, instead of digging for cooler ground. Put the pool over the spot the dog has been digging.
Digging in a particular area
The dog has one or more favorite spots to dig.
Slightly bury a wire mesh sheet in the areas the dog digs. When the dog starts to dig, his nails scrape on the mesh, causing an unpleasant sensatiion (not painful). When he goes to his other spots to dig and has the same experience, he will eventually get the idea that it isn't fun to dig anymore.
Digging out of boredom
Digging as entertainment
Get a "serious" chew toy or bone that you can stuff with treats. Look for hard rubber chew toys that are specifically made for this purpose. The toy will keep him busy for hours, trying to get the treat.
Digging all over
The dog loves to dig
Build a sandbox. Encourage the dog to dig there by burying small treats and praising him when he digs them up. Discourage him from digging in other areas of the yard by clapping loudly when he digs elsewhere. You'll need to watch him closely for a couple of days, or this training method could backfire. This is one of the most effective ways to discourage unwanted digging.