How Hreflang Tags Help a Multi-Language Site
Hreflang tells search engines that several pages are the same content in different languages or for different regions, and which to show whom. The Hreflang Tag Generator produces the set.
What it is for
Without it, a search engine sees your English and Spanish pages as separate pages that happen to be similar, and may show the wrong one - or treat them as duplicates competing with each other.
With it, each version declares the others, and the engine shows a Spanish-speaking visitor the Spanish page. It is a signal about which version to display, not a ranking boost, which is the expectation to correct first: hreflang does not make a page rank better, it makes the right page appear.
The reciprocity rule, which breaks most implementations
Every page in a hreflang set must list every page in the set, including itself. If your English page declares the Spanish one but the Spanish page does not declare the English one, the whole relationship is ignored.
That is the single commonest failure, and it happens because people add the tags to the page they are working on and not to the others. A set of five languages means five tags on each of five pages - twenty-five declarations. It is the kind of thing that wants generating rather than hand-editing.
Getting the codes right
The language code is ISO 639-1, two letters: en, es, de, fr. The optional region is ISO 3166-1 Alpha 2: GB, US, MX. Together they read en-GB, es-MX.
Two traps. The language comes first and the region second - en-GB, never GB-en. And a region alone is invalid: there is no hreflang="GB", because a region does not imply a language.
Use a region only when the content genuinely differs for it - different prices, different legal terms, different spelling conventions. Two identical English pages split by region gain nothing.
x-default, which almost nobody sets
hreflang="x-default" names the page to show when no other version matches the visitor. A language picker, or your main international version.
Without it, a visitor whose language you do not publish gets whatever the engine happens to pick. It is one extra line in the set and it covers everyone you did not anticipate, which is most of the world.
Common questions
Where do the tags go?
In the head of each page, or in the XML sitemap, or in HTTP headers. The head is simplest; the sitemap scales better across many pages.
Do I need it for one language in several countries?
Only if the content differs. Identical pages split by region are not worth the complexity.
How does it interact with canonical tags?
Each language version should be its own canonical. Pointing them all at one canonical cancels the hreflang.
What if a page exists in only some languages?
List only the versions that exist. Pointing at a missing page breaks the set.
Need a hreflang set generating?