Hreflang tag generator
Generate hreflang tags for international SEO — as HTML <link>, HTTP headers, or sitemap entries.
The fallback shown to visitors whose locale doesn't match any of the above. Usually your global homepage.
- Use a country code only when the language differs by region (es-MX vs es-AR). Otherwise just
es. - Every URL must reference EVERY locale — including itself. We do this automatically.
- Use absolute URLs, not relative paths. Google ignores relative hreflangs.
<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="es-ES" href="https://example.com/es/" /> <link rel="alternate" hreflang="x-default" href="https://example.com/" />
Drop these <link> tags inside <head> on EVERY language version of the page.
What hreflang actually does
hreflang tells Google which language and (optionally) regional version of your page to show each searcher. Done right, a French visitor in Quebec sees your French Canadian page, a French visitor in France sees your French page, and a Brazilian visitor sees your Portuguese page — all from the same canonical content.
Done wrong, Google ignores your hreflang setup entirely and serves whichever page it thinks is most relevant. The most common mistake is incomplete reverse-references: Page A references Page B, but Page B doesn't reference Page A back. That breaks the whole cluster.
Three ways to deploy hreflang
- <link> tags in <head> — most common. Drop the full set of tags into the <head> of every language version. Easy to manage in templates.
- HTTP headers — required for non-HTML resources (PDFs, downloadable files). Same data, sent as
Link:response headers. - Sitemap.xml entries — cleanest option for sites with hundreds of locales or pages. Each <url> entry includes
xhtml:linkrows pointing at every alternate.
Format rules Google enforces
- Language code uses ISO 639-1 (two-letter):
en,es,fr. Notenglish. - Region code uses ISO 3166-1 alpha-2:
US,GB,BR. Combined aslanguage-REGION:en-US,pt-BR. - x-default is the fallback for visitors whose locale doesn't match any of your declared ones. Almost always your global homepage.
- URLs must be absolute and use the same protocol (http or https) you're actually serving.
FAQ
Do I need hreflang if I only have one language version?
No. Hreflang exists to disambiguate between multiple versions of the same content. A single-language site doesn't need it.
Should I use language-only (en) or language-region (en-US)?
Language-only when the content is the same across regions (one English page for everyone). Language-region only when the content actually differs (different pricing, currency, or product availability for en-US vs en-GB).
Why do all my hreflang URLs need to reference each other?
Google requires reverse confirmation. If en-US says 'es-ES is over there' but es-ES doesn't say 'en-US is over here', Google can't trust either claim and ignores the cluster. The generator handles this automatically.
Can I mix HTML link tags and HTTP headers?
Yes — they're independent. Use whichever is easiest for each resource type. PDFs need headers because they have no <head>. HTML pages typically use link tags because they're easier to template.
How long until Google picks up changes?
It can take days to weeks for Google to re-crawl every URL in the cluster and rebuild the relationship graph. Submit the updated URLs via Search Console's URL Inspection tool to speed it up.
Should I include x-default?
Strongly recommended. Without it, searchers whose language doesn't match any of your declared locales might be served whichever page Google guesses — often the wrong one. x-default lets you control that fallback explicitly.
Get the full Web Design Service workspace.
Want this monitored daily across all your projects? Sign up free.