hreflang tag generator
Last updated: 2026-10-30
List each language or regional version of a page with its full URL, add an optional x-default page, and copy the hreflang annotations as HTML link tags, an XML sitemap or an HTTP header. The checker flags invalid codes (such as en-UK or jp), relative URLs and duplicates.
Every version must carry the same complete set of tags, including one pointing to itself; links that don't point back are ignored.
Runs in your browser. Nothing you enter is sent anywhere.
How it works
Language first, region optional
Each value is a language code (ISO 639-1, such as de), optionally followed by a region (ISO 3166-1 alpha-2, such as de-AT). A region on its own is not valid, and the United Kingdom is GB.
Every page lists every version
Each version carries the full set, including itself. If page A points to B but B does not point back, Google ignores the pair.
Three equivalent formats
HTML link tags in the head, entries in the XML sitemap or an HTTP Link header are equivalent; pick one method and use it consistently. URLs must be fully qualified.
x-default for everyone else
x-default names the page for visitors whose language or region none of your versions match, often a language picker or the main version.
Based on: Google: Tell Google about localized versions of your page
Do it for every page with GSC Magic
Once hreflang is live, check that Google indexes each version: GSC Magic lets your AI agent inspect the language URLs in batches and compare clicks by country.
Inspect our /de/, /fr/ and /es/ home pages and tell me which canonical Google chose for each.
Compare clicks by country for the English and German versions of our pricing page.
Questions
Is en-UK a valid hreflang code?
No. The ISO region code for the United Kingdom is GB, so use en-GB.
Do I need x-default?
It is optional but recommended when you have a page for visitors who match none of your languages, such as a language selector or your main version.
Should hreflang go in HTML or in the sitemap?
Either works. Sitemaps are easier for large sites because the tags live in one place; HTML tags are simpler for a few pages. Don't mix methods with conflicting values.
Does hreflang replace canonical tags?
No. Each language version should be canonical to itself; hreflang tells Google which version to show to which audience.
Guides on the blog: Alternate page with proper canonical tag: usually nothing to fix