barking dog is a bored dog
To prevent barking, you must show your dog that an alternative behaviour is more rewarding. Telling your dog to be quiet won’t work because there is no incentive for him to obey. In fact, barking is rewarding to your dog because he gets your full attention, so he will continue. In your dog’s mind, any attention, even being yelled at, is better than none at all. He may also interpret your yelling as you joining in the barking.
Your dog is more likely to bark in his own environment, such as when he sees or hears something unfamiliar. By exercising him and getting him out of his own environment, he will be more likely to rest when he is home.
Enrich your dog’s environment with a selection of activity toys to keep him occupied. These should include stuffed Kongs, Kong Wobblers, Tucker Balls, Home Alone Toys and a nice juicy raw bone.