About the Hreflang Generator
Hreflang annotations tell Google which language and region each version of a page is for, so searchers land on the right one. They are easy to get wrong: a misspelt code, a missing return link or a relative URL silently invalidates the set. List your language versions, and this generator checks each code, normalises its case, flags duplicates and writes the tags in the three formats Google accepts. Nothing is uploaded; it runs in your browser.
How to use the Hreflang Generator
- Add a row for each language version of the page, including the page itself, with its language code and full URL.
- Optionally set an x-default URL for visitors whose language is not on your list, such as a language selector.
- Fix any problems shown, then choose HTML, HTTP header or XML sitemap output.
- Place the same complete set on every version of the page, so each one links to all the others and to itself.
The formula behind it
Each tag has the form <link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />. The value is a lowercase ISO 639-1 language, optionally followed by a hyphen and an uppercase ISO 3166-1 region, or the keyword x-default.
Frequently asked questions
Do I need hreflang if I have one site in one language?
No. Hreflang only matters when you have more than one version of the same page for different languages or regions. A single-language site has nothing to annotate.
Should the language code be “en-UK” or “en-GB”?
Use en-GB. The region part is an ISO 3166-1 code, and the United Kingdom’s is GB. “en-UK” is a common mistake; the generator corrects it for you and tells you it did.
What does x-default do?
It names the page to show when none of your listed languages matches the searcher, usually a language selector or your main version. It is optional, but recommended.
Why does Google ignore my hreflang?
The usual causes are missing return links (version A points to B but B does not point back), URLs that redirect or are not canonical, relative URLs, and invalid codes. Every version must carry the complete set.
HTML, HTTP header or sitemap: which one?
Pick one method and keep it consistent. HTML tags suit most pages. The HTTP header is the option for non-HTML files such as PDFs. The XML sitemap is easiest to maintain when you have many pages and cannot edit every template.