GeoPromptTracker

Hreflang tags explained: syntax, examples, and common mistakes

Published July 18, 2026

Hreflang tags tell search engines which language and region each version of a page targets, so a UK visitor sees your en-GB page and a US visitor sees en-US — instead of the wrong version ranking or your translations competing as duplicates. The syntax is simple, but it's unusually easy to break, because every version must reference every other version, including itself.

What hreflang does

If you publish the same content in multiple languages or for multiple regions, search engines face a question: which version should rank for a given searcher? Without guidance they might show your Spanish page to English users, or treat your en-US and en-GB pages as duplicate content and suppress one. Hreflang answers the question explicitly: "here are all my versions, and here's the language/region each one is for."

The syntax

Hreflang lives in the <head> (or in your XML sitemap, or HTTP headers — the head is most common). Each version of the page lists all versions, including itself:

<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="es" href="https://example.com/es/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

The hreflang value is:

  • An ISO 639-1 language code (en, es, de, fr) — required.
  • Optionally a hyphen and an ISO 3166-1 Alpha-2 region code (en-us, en-gb, es-mx) — use only when you genuinely target regions, not just languages.

Note the codes people get wrong: it's en-gb, not en-uk (UK is not the ISO country code). Language first, region second — never the reverse.

x-default: the fallback

x-default names the page to serve when no specific version matches the user — usually a country/language selector or your primary international page. Always include it; without it, unmatched users get whatever the algorithm guesses.

The rule that breaks everything: return links

This is where most hreflang implementations fail. Hreflang must be bidirectional. If page A says "B is my German version," then page B must say "A is my English version." If the return link is missing, search engines ignore the entire annotation as untrusted. Every version pointing to every other version — including a self-reference — is not optional; it's the thing that makes hreflang work at all.

The common mistakes

  1. Missing return tags. A → B without B → A. The single most frequent hreflang failure; it silently voids the whole set.
  2. No self-referencing tag. Each page must list itself. Omitting it invalidates the group.
  3. Wrong codes. en-uk (should be en-gb), region-first (us-en), or made-up codes. Use ISO 639-1 + ISO 3166-1 only.
  4. Relative URLs. hreflang href must be absolute (https://…), like canonical and og:image.
  5. Mixing with conflicting canonicals. Each language version should canonical to itself, not to one "master" version — a canonical pointing all versions at the English page tells Google to drop the others, cancelling your hreflang.
  6. Only some pages annotated. Hreflang is per-URL. Every page in the set needs the full annotation, not just the homepage.

Does hreflang matter for AI search?

Mostly as a correctness signal. AI systems that lean on search indexes benefit when your regional versions are cleanly separated and consolidated — the right version stays indexed and citable. It's not a ranking lever, but a broken hreflang setup can split or bury your international content, which hurts every channel including AI. If you serve multiple regions, getting it right is table stakes.

Generate it without the errors

Because hreflang is so easy to break — one missing return tag voids the set — hand-writing it across many pages is risky. Our free Hreflang Tag Generator takes your language/region → URL matrix and outputs the complete, bidirectional set of <link> tags (and matching XML sitemap entries), with x-default and self-references included so nothing is missed. Enter your versions, copy the output, and paste the same full block into every page's head.

Bottom line

Hreflang is conceptually simple — "this version is for this language/region" — but mechanically strict: absolute URLs, correct ISO codes, self-references, and above all reciprocal return links on every version. Get those right and the correct page ranks for the correct audience; miss one and the whole annotation is ignored. When in doubt, generate the full set rather than typing it by hand.

Frequently asked questions

What are hreflang tags?

Hreflang tags are HTML annotations that tell search engines which language and region a page targets, so they show the right version to the right user — for example, serving the en-GB page to UK searchers and en-US to American ones. They prevent the wrong-language version from ranking and reduce duplicate-content confusion.

What is the correct hreflang syntax?

Use <link rel="alternate" hreflang="en-us" href="https://example.com/us/" /> in the head, one per language/region version, with an ISO 639-1 language code optionally followed by an ISO 3166-1 region code. Every version must link to every other version, including itself.

What is hreflang x-default?

x-default specifies the fallback page for users whose language/region doesn't match any of your specific versions — typically a language selector or your main/international page. Add it as hreflang="x-default" alongside your other hreflang tags.

Do hreflang tags help with AI search?

Indirectly. Hreflang keeps the correct regional version indexed and consolidated, which helps AI systems that draw on search indexes cite the appropriate version. It's a correctness signal more than a ranking boost — but getting it wrong can split or bury your international pages.

Related