Dogs always bark for a reason. They may be alerting you to something, like the fact that someone's at the door, there's a killer squirrel outside, or that homicidal UPS man is on your street. They may be demanding your attention, either from another room or right in front of you. They may be trying to get another dog (or cat) to play with them, or their ball is trapped under something, etc.
Whatever the reason, a dog that barks and barks is just plain annoying. While a couple of barks to let you know someone is at the door or in front of your house is your dog doing his job, you don't need to be told over and over. And wouldn't it be better if he just came to get you without barking at all! How you handle the barking will vary a bit depending on the circumstances.
I want your attention!
If your dog is in his crate or standing in front of you and barking his head off, you need to ignore him. Completely. No eye contact, no talking to him, nothing. If circumstances allow you to move away from him, or even disappear, even better. You want to give him the message that barking either gets him nothing or actually makes you (the thing he wants) go away.
As soon as he's quiet, even for an instant, turn to him and praise him and give him the attention he's demanding. If he's in his crate and you can let him out (see the Crate Training Tip if you are crate training), do so calmly. Now he sees he gets what he wants (in this case, your attention or being released from his crate) for being calm and quiet.
There's something out there!
If your dog likes to stand at the window and bark his head off, don't join him by yelling at him to stop. Instead, wait for that moment of silence. Most dogs don't really bark continuously. It's more like "bark, bark, bark.....(pause)...bark, bark, bark...(pause)..." etc. Wait for the pause. Patience is key. As soon as he's quiet, even for a moment, call him to you in a high happy voice and offer him a distraction, like a squeaky toy, tug toy (and play with him a little), or bully stick (a chew treat that lasts a while). If you call him away and offer these things while he is barking you will actually be rewarding (and therefore reinforcing) the barking. Get that moment of quiet so you can reward and reinforce the quiet.
You should also show your dog you don't need him to let you know there's someone there by being proactive when you can. When you're expecting someone -- take out food, a repair man, company -- that is due to arrive in a window of time, try to be on the lookout or have them text you as they turn onto your street. Now you can be at the door before they arrive showing your dog that you KNOW there is someone out there and you've got things under control.He can relinquish his job of alerting you.
Once your dog has learned to stop after a couple of barks, or not bark at all, continue to reward and reinforce by praising him or offering a treat for giving you the calm behavior.