Each row becomes one hreflang annotation. The language must be a real ISO 639-1 code and the region must be two letters, so most of the usual mix-ups get flagged before they ship: cn for Chinese (that's not a language code, you want zh-CN) and jp for Japanese (the language is ja) are rejected with the code you probably meant, while a bare uk raises a warning because it is valid but means Ukrainian, not the United Kingdom (you want en-GB). Duplicate language-region pairs and relative URLs are rejected too, since both invalidate the set. The region is only checked for being two letters, not looked up in the ISO list, so en-UK is not caught; the table below shows what is and isn't.
The output is written for you to paste onto every page in the group, unchanged. That's deliberate: the block lists every version in the set, so each page carries a tag pointing at itself as well as at the others, which is what makes the annotations reciprocal and therefore valid. Everything runs in your browser and nothing is uploaded.
The rules a valid hreflang set follows
Hreflang is only trusted where the references agree with each other. These are the conditions that matter:
- Every page lists itself. Each page in the set carries a tag for its own URL, not only for its translations.
- Every pair points both ways. If page A names page B as an alternate, B must name A back. One-way references are ignored.
- The set is identical on every page. Same codes, same URLs, in whichever method you use.
- Language first, region optional. An ISO 639-1 language (
en), optionally followed by an ISO 3166-1 alpha-2 region (en-GB). A region can never stand alone. - Every URL is absolute, canonical and live. A full
https://address that returns 200, can be indexed, and is its own canonical rather than a redirect, a noindex page or a page canonicalised to another language. - x-default is optional. It names the fallback page for visitors who match none of your versions.
Worked example: a site with three versions
A site has a US English home page, a UK English version and a German version. These are the rows to enter, with the home page as the x-default:
| Language | Region | URL for that version |
|---|---|---|
| en | US | https://example.com/ |
| en | GB | https://example.com/uk/ |
| de | (blank) | https://example.com/de/ |
| x-default | n/a | https://example.com/ |
The HTML head tab produces this block:
<link rel="alternate" hreflang="en-US" href="https://example.com/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />Paste it unchanged into the <head> of all three pages. Each page now has a tag for itself and a tag for each of the others, so every pair points both ways. The XML sitemap tab produces a single entry, built around the first row:
<!-- Requires xmlns:xhtml="http://www.w3.org/1999/xhtml" on the <urlset> element -->
<url>
<loc>https://example.com/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/" />
<xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/" />
</url>For a sitemap, add one <url> entry per version (here /, /uk/ and /de/), changing only the <loc> and keeping the xhtml:link lines identical. The set describes one page: the pricing page and its translations are different URLs, so run the generator again for them.
Choosing an implementation method
| Method | Best when | Trade-off |
|---|---|---|
HTML <link> tags in the head | You control the page templates and the site has a manageable number of pages. | Adding a language means editing every existing version, and each page carries one tag per version. |
XML sitemap with xhtml:link | The site is large, or you cannot edit page heads in your CMS or hosting. | Each version needs its own entry, and one sitemap file holds at most 50,000 URLs, so three versions of every page cap a file at roughly 16,600 pages. The markup is also invisible in view source. |
HTTP Link header | The files have no head, mainly PDFs. | Set in the server or CDN configuration. This generator produces only the HTML and XML forms, not the header. |
Pick one method per set of URLs: two sources that disagree are worse than one. The hreflang guide has a sitemap and a header example.
Common hreflang mistakes, and what this generator does about them
| Mistake | Why it breaks | This generator |
|---|---|---|
| Missing return link | The pair is ignored. | Cannot see it: it builds a set but fetches no pages. Check each live version with the Hreflang Validator. |
| Page leaves itself out of the set | Each version is expected to list itself as well as the others. | Not checked. Include the page you are pasting onto as one of the rows. |
en-UK instead of en-GB | UK is not the ISO code for the United Kingdom, so the region is not recognised. | Not caught. Any two-letter region is accepted. |
jp, cn, gb, us or dk as a language | These are country codes, not language codes. | Rejected, with the code you probably meant. A bare uk gets a warning. |
es-419 or a region on its own | A language is required, and the region must be a country code. | Rejected: a blank language and a region that is not two letters are both errors. |
| Relative URLs, or the same code twice | Alternates must be fully qualified and unambiguous. | Rejected. |
| Alternate that redirects, returns 404, is noindex or is canonicalised elsewhere | Google can ignore those annotations. | Not checked. Test each URL with the Redirect Chain Checker and the Canonical URL Analyzer. |
Script subtags such as zh-Hant | Valid in hreflang, but the region slot only takes two letters here. | Cannot be produced. Use zh-TW or write that tag by hand. |
& inside a URL in the XML output | An unescaped ampersand makes the sitemap invalid XML. | Not escaped for you. Write & yourself in the XML. |
| Redirecting visitors by IP or browser language | Crawlers may never reach the other versions. | Out of scope. Offer a language picker or a banner instead of redirecting. |