Hreflang tag generator.
Add each language and region version of a page with its full address, and the tool builds hreflang tags in 3 formats: HTML link tags, an HTTP Link header, and XML sitemap entries. It checks every code against the ISO 639-1 and ISO 3166-1 lists and flags a page that does not point to itself.
Optional. Used to check that this page lists itself.
Every version has to carry the same set of tags, itself included. Codes use ISO 639-1 for the language and ISO 3166-1 for the region. See Google's guide to localized versions.
This tool runs in your browser. Nothing you enter is sent anywhere or stored.
How to use it
- Add the page you are tagging Enter the full address of the page that will carry the tags. The tool uses it to check that the page lists itself.
- Add one row per version Enter a language such as en or a language and region such as en-GB, then the full address of that version. Add x-default for the page that catches everyone else.
- Fix anything flagged Unknown codes, repeated codes, and addresses that are not complete are marked on their row, with a suggested fix.
- Copy the format you need Use link tags in the head of every version, a Link header for files such as PDFs, or sitemap entries if you would rather keep the tags out of your pages.
Why it matters
Hreflang tells Google which version of a page is meant for which language and region, so a visitor in Canada can be shown the Canadian French page and not the English one. Google says every version should list all the versions, itself included, and the set of tags should be the same on each page. When 2 pages do not point to each other, the tags are ignored.
Most mistakes come from the codes. The language comes first and uses the 2-letter ISO 639-1 list. The region is optional, follows it, and uses the 2-letter ISO 3166-1 list. A region on its own is not valid, so US alone does nothing, and a code Google lists as reserved, such as UK, has no effect. The code for the United Kingdom is GB. Google also does not support values like es-419. Casing is not enforced, but en-GB is the usual way to write it.
The x-default value is the fallback for visitors whose language you do not cover. Google recommends it and says it works best on a language selector page. Pick the method that fits how you publish: link tags in the head work for most sites, the Link header suits non-HTML files such as PDFs, and a sitemap keeps the tags out of the page when you have many versions. Choose 1 method per set of pages so there is only 1 place to maintain.
Sources
Questions
Do I need hreflang if my site has 1 language?
No. Hreflang only helps when the same page exists in several languages or for several regions.
Should the addresses be complete?
Yes. Google asks for fully-qualified URLs for every version, including the https:// part.
What does x-default do?
It names the page for visitors whose language and region match none of your versions. Google designed it for language selector pages, though you can use it on any page.
Why does the tool want my page to list itself?
Google asks for a link for each version of the page including itself, with the same set on every page. Leaving the page out is one of the most common gaps.
Is a region code required?
No. A language alone, such as de, covers that language everywhere. Add a region only when the content differs by country, such as prices in a different currency.
Keep going
Read the Doily guides for step-by-step playbooks. To track results over time, see Doily's SEO tools.