hreflang Generator + Linter

Most broken hreflang deployments fail the same way: page A lists page B, but B never lists A back. Build the set here and every URL references every other and itself, so the set is bidirectional by construction — that mistake can't happen. A linter flags wrong codes, duplicates, and missing fallbacks as you type.

Example data — replace with your own

One row per locale version of the same page. Paste a URL with /de/ or a de. subdomain and the locale fills itself in. Use arrow keys to move between cells; Enter on the last row adds a new one. The optional per-row x-default lets each page point unmatched users somewhere different (e.g. a localized language selector) — leave it blank to use the shared one below.

hreflangURLx-default (optional, per page)Remove
What this result means ↓
Add a locale and URL above to see output.

Runs entirely in your browser — nothing you paste is uploaded or stored. Anonymous run-level outcome counters may be used for aggregate research; URLs, domains, IPs, and identifiers are never included, and no statistic is released below 100 runs.

Check a live URL

Fetch a page you've already deployed: we read its live hreflang annotations, then fetch each declared alternate (up to 25) to verify return links and self-references.

Sample report Example data — real, generator-verified result

A US and UK English site, with a generic en fallback and an x-default, produces head tags like:

<link rel="alternate" hreflang="en-US" href="https://example.com/us/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="en" href="https://example.com/us/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

…and running that cluster through the built-in linter reports:

  • Codes are normalized for you. Type en-us or en-US — the generator always emits the uppercase region form (en-US), so casing typos never become a problem.
  • The generic en is what makes this clean. It catches English speakers outside the US and UK who'd otherwise match nothing — see regional variants without a generic fallback.
  • x-default catches everyone else — see missing x-default for what happens without it.
  • Bidirectionality isn't visible in one page's tags — but because this generator emits the same complete block on every page in the set, every listed URL also lists this one back, automatically.
  • Try breaking it: paste en-uk instead of en-gb and the linter flips to an error pointing at the fix — see code format.

How to use it

  1. Add a row per page and a column per locale, then fill in the URL for each language/region version.
  2. Optionally set an x-default (per row) and let the tool auto-detect locales from your URLs, or paste an existing sitemap to import a cluster.
  3. Copy the output in whichever form you need — head tags, sitemap XML, or HTTP Link headers. Every page gets the complete, bidirectional, self-referencing cluster.
  4. Paste your live markup (or check a URL) into the linter to catch the common mistakes before you ship.
Feedback
Report a bug

Found something broken in Hreflang Generator? Let us know what happened — this goes straight to a private triage queue, not a public list.

What will be sent
 No tool inputs, uploads, pasted source, complete results, query parameters, or URL fragments are attached automatically. You can edit or remove the selected passage above. Browser and anti-abuse metadata is processed for spam prevention. 

Checks run from our server; we fetch the URL you enter and don't keep the results. Anonymous aggregate outcomes feed our research posts; checked domains are counted once via an anonymized hash, never stored in the clear. Anonymous run-level outcome counters may be used for aggregate research; URLs, domains, IPs, and identifiers are never included, and no statistic is released below 100 runs.

How it works (and how hreflang breaks)

Choose a hreflang delivery format

HTML head tags

Use it when: you control the HTML templates for ordinary web pages.

Usually the clearest choice: render the full same cluster in every page head.

XML sitemap

Use it when: templates are hard to change or you manage many URL variants centrally.

Use xhtml:link entries consistently and keep the sitemap accessible to crawlers.

HTTP Link header

Use it when: the alternate is a PDF or another non-HTML resource.

This is the practical option for files that have no HTML head. Avoid mixing methods without a reason.

hreflang tells search engines which language/region versions of a page exist so each searcher gets the right one. Three delivery methods are equivalent: <link rel="alternate"> tags in the <head>, xhtml:link entries in an XML sitemap, or HTTP Link headers (the only option for PDFs and other non-HTML files). Pick one method per page — mixing them invites conflicts.

The two rules that break most implementations: every page must include a self-referencing entry, and every pair must be bidirectional — if A lists B, B must list A back or the pair is ignored. Because this generator emits the complete cluster on every page, both hold automatically.

Regional variants without a generic fallback

If you publish en-US and en-GB but no plain en, English speakers in Australia, Ireland, or India match nothing and Google picks for them. Add a generic en entry (it can point at whichever regional page you treat as the default).

Missing x-default

x-default names the page for users who match no declared locale — typically your language selector or your primary version. It's optional, and this tool only warns about it, but explicit beats letting the algorithm choose.

A standalone language-selector page needs the annotations too: place the same head-tag block on it — the x-default line is its self-reference, so the cluster stays bidirectional. In the sitemap output, a selector URL that isn't one of the locale pages automatically gets its own annotated <url> entry.

x-default is also a per-page annotation: pages in the same cluster may point at different x-defaults — the French page at a French-language selector, the English page at an English one. Use the per-row x-default column for that; when pages differ, the head-tag and Link-header output switches to one block per page, and each distinct selector gets its own annotated sitemap entry.

Mixed http/https and inconsistent trailing slashes

hreflang URLs must match the canonical URL exactly. If half your entries say http:// or drop the trailing slash your site redirects to, those alternates point through redirects — Google often discards them. Use the final, canonical form of every URL.

Deprecated language codes

A few ISO 639-1 codes were renamed and linger in old CMS exports: inid (Indonesian), iwhe (Hebrew), jiyi (Yiddish). Search engines mostly tolerate the old forms, but use the modern codes.

Code format

Values are language or language-REGION: ISO 639-1 language (two letters) plus optional ISO 3166-1 alpha-2 region. The classic trap is en-uk — the United Kingdom's region code is GB. Script subtags like zh-Hant / zh-Hans are also valid. Underscores (en_US) are not. Matching is case-insensitive, so casing is cosmetic.

Browse language and region codes

Search the ISO 639-1 language and ISO 3166-1 region codes the generator accepts. Deprecated language aliases are shown with their replacement.

Languages (188)

aaabaeafakamanarasavayazbabebgbhbibmbnbobrbscacechcocrcscucvcydadedvdzeeeleneoeseteufafffifjfofrfygagdglgngugvhahehihohrhthuhyhziaidieigiiikin → idioisitiuiw → hejaji → yijvkakgkikjkkklkmknkokrkskukvkwkylalblglilnloltlulvmgmhmimkmlmnmo → romrmsmtmynanbndnengnlnnnonrnvnyocojomorospapiplpsptqurmrnrorurwsascsdsesgsiskslsmsnsosqsrssstsusvswtatetgthtitktltntotrtstttwtyugukuruzvevivowawoxhyiyozazhzu

Regions (249)

ADAEAFAGAIALAMAOAQARASATAUAWAXAZBABBBDBEBFBGBHBIBJBLBMBNBOBQBRBSBTBVBWBYBZCACCCDCFCGCHCICKCLCMCNCOCRCUCVCWCXCYCZDEDJDKDMDODZECEEEGEHERESETFIFJFKFMFOFRGAGBGDGEGFGGGHGIGLGMGNGPGQGRGSGTGUGWGYHKHMHNHRHTHUIDIEILIMINIOIQIRISITJEJMJOJPKEKGKHKIKMKNKPKRKWKYKZLALBLCLILKLRLSLTLULVLYMAMCMDMEMFMGMHMKMLMMMNMOMPMQMRMSMTMUMVMWMXMYMZNANCNENFNGNINLNONPNRNUNZOMPAPEPFPGPHPKPLPMPNPRPSPTPWPYQARERORSRURWSASBSCSDSESGSHSISJSKSLSMSNSOSRSSSTSVSXSYSZTCTDTFTGTHTJTKTLTMTNTOTRTTTVTWTZUAUGUMUSUYUZVAVCVEVGVIVNVUWFWSYEYTZAZMZW

Frequently asked questions

Where do hreflang tags go — the head, the sitemap, or an HTTP header?

Any of the three, and they are equivalent — but pick one method per page. Use <link rel="alternate"> tags in the HTML head, xhtml:link entries in an XML sitemap, or an HTTP Link header (the only option for non-HTML files like PDFs). Mixing methods on the same page invites conflicts.

What is x-default and do I need it?

x-defaultx-default is the reserved hreflang value that points to a fallback URL — the page Google shows when a user's locale doesn't match any of your other hreflang tags. It is optional and does not mean "English." names the page to serve users who match none of your declared locales — typically a language selector or your primary version. It is optional, but explicit is better than letting the algorithm choose, so it is recommended for most sites.

Why are my hreflang tags being ignored?

Almost always one of three things: the annotations are not bidirectional (page A lists B but B does not list A back), a page is missing its self-referencing entry, or the URLs do not match the canonical form (http vs https, or a trailing slashA trailing slash is the forward slash (/) at the end of a URL — example.com/page/ versus example.com/page. Except at the bare root domain, the two versions are different URLs to search engines, so you pick one format and enforce it. your site redirects) so they point through redirects. This generator emits the complete bidirectional cluster with self-references to prevent the first two.

Do hreflang and canonical tags conflict?

They must agree. Each language version should have a self-referential canonical (pointing to itself, not to another language), and every hreflang URLHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. must be the canonical form of that page. A hreflang that points at a non-canonical or redirecting URL is frequently dropped.

Is en-uk a valid hreflang value?

No. The region code for the United Kingdom is GB, so use en-gb. hreflang values are an ISO 639-1 language code plus an optional ISO 3166-1 alpha-2 region code; en-uk is the single most common mistake.

Feature requests for Hreflang Generator

Upvote what you want most. New ideas can be submitted from the floating Feedback menu; requests appear here once approved, and the most-wanted rise to the top.

Loading…

➕ Request a feature

New requests are reviewed before they appear here.

Next stepSEO Incident Simulator — practice the same investigation on labeled fixtures.