What's the deal with "however"? It usually just means "but" or "nonetheless," yet it's trickier to punctuate and place. So why do we use it at all?
Just think "whatever."
"Whatever" is, after all, the sibling of "however." They're formed the same way and came into being at the same time — the late 1300s. The "ever" originally just added emphasis and implied "of all things." We still use the words that way: "You can have whatever food you want and however you want it cooked."
Since "however" is an adverb, it can be used to modify adjectives: "However skilled you are, you will make mistakes"; "However much you want it, you can't have it." And this is where it started to shift over: It was used to mean "however much," as in Shakespeare's "Howe'er thou art a fiend, A woman's shape doth shield thee" (from King Lear in 1608).
We see the next step in its shift in Shakespeare, too: in The Two Gentlemen of Verona (1616):
If haply won, perhaps a hapless gain;
If lost, why then a grievous labour won;
However, but a folly bought with wit,
Or else a wit by folly vanquished.
In other words, "however it happens." You can see that this is similar to how we use "whatever": "Could be a win, could be a loss, whatever — it's folly."
And so "however" came to stand in for "however much" or "however it may be" as a comment on a whole clause. Shakespeare's late play Henry VIII (from 1623, and co-authored with John Fletcher) has it in that sense: "All the land knows that: However, yet there is no great breach." In the span of 15 years, it had added a whole new usage to its original sense — no longer just an adverb, it was now also a conjunctive adverb!
Imagine "whatever" being used that way: "He said he would bring a cake; whatever, it wasn't a cake he brought." That doesn't sound very formal, does it? We could expect it to be roundly rejected as a grotesque innovation by the same people who use "however" the most: those most concerned with sounding erudite.
Does that seem an unfair characterization? Consider this: In modern American and British fiction, "however" is used 2–3 percent as often as "but" (these numbers come from a survey of the British National Corpus and the Corpus of Contemporary American English). In modern American and British academic writing, on the other hand, it's used about 34 percent as often. And at Wikipedia, it's used 36 percent as often! And, yes, nearly all of these uses are as a conjunctive adverb.
Why so much in Wikipedia? Partly because the authors want to sound academically weighty, of course, and partly because Wikipedia has a lot of narrative, with its attendant turns and adversities — and partly because it is written and revised by multiple people. Every time someone adds a new perspective that contradicts something already in the article, it needs a conjunction to signal the shift: "Fats, such as butter or eggs, slow down yeast growth; however, others say the effect of fat on dough remains unclear, presenting evidence that small amounts of fat are beneficial for baked bread volume." This also helps explain why less than 1 percent of uses of "however" in Wikipedia are at the end of a sentence (a bit less than in academic writing and about a quarter of the proportion in fiction).
Why use "however" at all? For one thing, it's longer and weightier than "but" and is associated with more thoughtful or technical writing. For another, you can always get away with using it at the start of a sentence — you risk scorn by starting a sentence with "but" if your text is at all formal or your audience is particularly crusty (there's no real rule against using "but" to start a sentence, but there's a fake rule that a lot of people really believe).
Some people may tell you that you shouldn't use "however" to mean "nonetheless" at the start of a sentence or clause; however, they're wrong. This idea may have gotten its start in the fact that you can't do the equivalent in Latin, but (odd that this has to be pointed out) English is not Latin; English and Latin grammar are markedly different in many ways, and there are many things you can or must do in Latin that you must never do in English. Strunk and White assert, in The Elements of Style, that if you use it at the beginning of a sentence it must mean "in whatever manner," but this is one of many cases where they made something up out of peevish thin air. The distinction is easily made with a comma: "However you make it, a margarita should have some salt. However, you make it too salty." Notice that when it's meaning "in whatever manner," the whole phrase it applies to is adverbial — it can't be the main clause, so there will eventually be a comma, and a whole clause after it.
So how should we use "however" when we mean "nonetheless"? You can use it at the start or end of a sentence or clause as a general comment on the whole thing, or you can use it at any key juncture in a sentence (after the subject, the predicate, or a prepositional phrase, for instance) to point up the contrast on that element: "The bartender, however, poured the drink slowly into the glass"; "The bartender poured the drink slowly, however, into the glass"; "The bartender poured the drink slowly into the glass, however, and handed it over." Your ear will tell you well enough where it sounds awkward. Just make sure it has punctuation marks on either side of it, and at least one of them must be a comma — the other can be a period or a semicolon.
An important detail, if you want to follow the rules carefully, is that if "however" has commas on both sides, the sentence still has to work if you remove the "however" and both commas. If it doesn't, you need a semicolon in place of one of the commas, because there would be a period there otherwise, and that semicolon is the period plus a comma. "The dog, however, got sick" is fine, because you can write "The dog got sick"; "The cat was fine, however, the dog got sick" doesn't work, because you can't write "The cat was fine the dog got sick." You need "The cat was fine; however, the dog got sick."
Why does this matter, especially since so many people don't heed this rule? The formal reason is that the "however" is a comment on the whole clause, so it has to be set apart, but the more persuasive justification is that we haven't lost the original sense of "however," and if we don't use the commas there's a risk of ambiguity. Consider: "You shouldn't write it however you want to" means don't write it in just whatever way you want; "You shouldn't write it; however, you want to" means that you want to write it although you shouldn't. There won't always be this risk of ambiguity; it's best to keep in the habit, however.
Or you could just use "but."