How to use the hreflang tags generator
- 1Enter a Code and URL for every language or region version, including the page you're on. Use Add language for more rows.
- 2Keep the x-default row and point it at the page for everyone else (often the homepage or a language picker).
- 3Fix anything flagged under a row, such as en-UK or en_US.
- 4Choose the Output format and press Copy or Download. Add the same set to every version.
Example: English, UK English and German
en → https://www.example.com/ en-GB → https://www.example.com/uk/ de → https://www.example.com/de/ x-default → https://www.example.com/
<link rel="alternate" hreflang="en" href="https://www.example.com/"> <link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/"> <link rel="alternate" hreflang="de" href="https://www.example.com/de/"> <link rel="alternate" hreflang="x-default" href="https://www.example.com/">
Typing en-UK instead shows: “UK isn't an ISO 3166-1 country code. Use en-GB.” Codes are normalized, so en-gb becomes en-GB.
Language and region codes
An hreflang value is a language, optionally followed by a region: de (German, anywhere), de-AT (German for Austria), zh-Hant-TW (Traditional Chinese for Taiwan). The language must be a two-letter ISO 639-1 code and the region a two-letter ISO 3166-1 country code. A region on its own (GB) isn't valid. The generator checks both parts and shows the language and country names so you can spot typos.
Return links: every version lists every version
Hreflang works only as a complete, two-way set. If the English page says the German page is its de version, the German page must link back to the English page, and each page must also list itself. When the links don't match, search engines ignore the annotations for those pages. In practice: generate the set once, then put the identical block on every version.
x-default explained
x-default tells search engines which URL to show to searchers whose language or region doesn't match any version you list. It's usually the homepage that redirects by language, a language picker, or your main international version. It isn't required, but without it, someone searching in Italian on a site with only English and German may land on either one.
HTML vs sitemap vs HTTP header
| Method | Best for | Notes |
|---|---|---|
<link> tags in <head> | Small and medium sites | Adds a few lines to every page |
| XML sitemap | Large sites, many languages | Keeps page HTML small; each <url> lists all versions |
HTTP Link header | PDFs and other non-HTML files | Needs server configuration |
Use one method per page. Mixing them is allowed but makes mistakes harder to find.
Common hreflang mistakes
- Wrong codes:
en-UK(should been-GB),en_US(underscore),es-LA(no such country), or region numbers such ases-419, which Google doesn't support. - Missing return links or missing self-references.
- Pointing to redirects or non-canonical URLs: each URL should return 200 and be the canonical version.
- Relative URLs: hreflang needs absolute URLs.
- One code, two URLs: each code may appear once per set.
Is anything I enter stored?
This tool runs entirely in your browser. Your text is not uploaded to our servers.
