Fido is smarter than you think. Here’s what’s going through his head: “So…if I bark when I’m outside, I get a treat!” You need to change his perception. He needs to associate the treat with being quiet.
Here’s what you do instead. Let your dog out. When he starts barking, go outside, hiding a treat in your hand. Sit down and completely ignore him. When he comes to investigate, he’ll stop barking. Give him the treat, and go back inside. If he starts barking again, go through the same routine.
But what if he sits in a window and barks whenever anyone walks by? The secret to making him stop is to make sure you’re rewarding him for the behavior you want, rather than using rewards to distract him from the behavior you don’t want.
If you offer him a treat to distract him from barking, that’s a reward. Instead, just sit down quietly with a treat in your hand. When he comes to investigate, that’s the time to reward him. Then, he’ll associate the treat with coming to investigate rather than with barking.