Skip to main content
SerpGem
Technical SEO

hreflang Generator

Build valid hreflang tags for multi-language or multi-region sites — with auto-validation of language codes, duplicate detection, and both HTML and XML sitemap formats.

How to use this tool3 quick steps
  1. Add a row for each language/region

    Use BCP 47 locale codes: en, en-us, en-gb, fr, fr-ca, etc. Always include x-default as the fallback for users who don't match any locale.
  2. Choose HTML or XML format

    HTML <link> tags go inside <head> on every alternate-language page. XML sitemap entries go inside a <loc> block in your sitemap.xml.
  3. Self-referencing is required

    Every language version must include a hreflang tag pointing to itself. Google ignores one-sided implementations — all pages must reference each other.
InputLanguage-URL pairs
OutputHreflang tags

Use this with

See all 9 tools

hreflang Guide

The tag that tells Google which locale to show

When you have multiple language or regional versions of the same content, hreflang tells Google 'this English page and this Spanish page are the same article — show the right one based on the user's locale.' Without hreflang, Google often shows the wrong version and splits your ranking signals.

Language-region format

Use ISO 639-1 language codes (en, es, fr) optionally paired with ISO 3166-1 country codes (en-us, en-gb, es-mx). 'en-us' targets American English; 'en' targets English-speaking anywhere.

x-default is mandatory-ish

Set x-default for the fallback URL when no locale matches — typically the English or global version. Google strongly recommends it, and omitting it can cause the wrong version to rank in unsupported regions.

Reciprocal linking required

If the English page points to the Spanish one, the Spanish page MUST point back to the English one (and to itself). Missing return links invalidate the entire hreflang cluster — Google ignores it.

Self-reference required

Every page must include a hreflang pointing to itself. e.g., the English page has hreflang="en" pointing to its own URL. This is part of the reciprocal structure.

Three places to put hreflang

HTTP headers, HTML <head>, or sitemap XML — pick ONE method per page. Using multiple locations increases error risk and doesn't improve signal. Sitemap is easiest for large sites.

Canonical and hreflang together

Each regional page should self-canonicalize. Never canonicalize the Spanish page to the English one — that tells Google to ignore the Spanish version and defeats the purpose of having it.

Pro Tips

Validate in Search Console

Search Console's International Targeting report (under Legacy Tools) lists hreflang errors. Missing return tags and unknown language codes show up here — fix within 48 hours.

Regional override

Use 'en-us' only when you genuinely have US-specific content (pricing, policies, spelling). For generic English, just use 'en' — simpler and catches all English speakers.

Script codes for CJK

For Chinese, specify script: 'zh-Hans' (Simplified) vs 'zh-Hant' (Traditional). Serbia has 'sr-Latn' vs 'sr-Cyrl'. These live between the language and region codes.

?

Frequently Asked Questions

Can I use only language codes without regions?
Yes. 'en' targets all English speakers; 'en-us' narrows to the US specifically. Use region codes only when content actually differs by region (pricing, shipping, spelling). Otherwise keep it to just language.
HTML tags vs XML sitemap — which is better?
Functionally equivalent. HTML tags are easier to verify by viewing source. XML sitemap scales better for sites with hundreds of pages. For 10+ locales, XML usually wins; for small sites, HTML is simpler.
What happens if I miss a reciprocal tag?
Google invalidates the entire hreflang cluster for that page. The page stays indexed, but Google stops using hreflang to pick the right version. This is the #1 hreflang bug — test thoroughly after launch.
Does hreflang help rankings?
Not directly — it doesn't boost ranking. It ensures the RIGHT version ranks in the RIGHT market. A Spanish user searching in Mexico will see your Mexican Spanish page instead of your US English page. That's a UX and CTR win, which is worth a lot.