Hreflang Tag Generator
Build correct rel="alternate" hreflang link tags for multilingual and multi-region sites. Validates ISO 639-1 language and ISO 3166-1 region codes, handles the x-default fallback, and exports as HTML <link>, HTTP header or XML sitemap.
What is a hreflang tag generator?
A hreflang tag generator builds the rel="alternate" hreflang="…" link tags Google and Yandex use to serve the right language or country version of your page to each user. Hreflang is the cornerstone of international SEO: it tells search engines that example.com/en/, example.com/fr/ and example.com/de/ are translations of the same content — preventing duplicate-content penalties and making sure French users land on the French page in Google search results.
This hreflang generator runs entirely in your browser. Add one row per language or country variant, paste the URL, and the tool outputs valid <link> tags ready to paste into <head>. Need a different delivery method? Switch to HTTP header (for PDFs and non-HTML files) or XML sitemap (for large sites). Built-in validation flags invalid ISO codes, missing self-references and broken reciprocity.
How to use the hreflang generator
- Add a row for each language or country variant of your page using the + Add language button.
- Pick a language (ISO 639-1:
en,fr,es…). The region is optional — only add it when you target a specific country. - Enter the absolute URL for that variant (must include
https://). - Add an
x-defaultURL — the fallback Google uses when no other variant matches the user's language. Strongly recommended. - Switch output format at the top: HTML
<link>tags (most common), HTTPLinkheader (for non-HTML files), or XML sitemap (for large sites). - Check the validation panel for invalid codes, missing self-references, or duplicate locale entries.
- Copy or download the generated block and paste it into your site.
Hreflang syntax explained
The hreflang value follows the IETF BCP 47 standard, which on the practical level means language[-REGION]:
- Language only —
hreflang="en"targets every English speaker regardless of country. - Language + region —
hreflang="en-GB"targets English-speaking users in the United Kingdom. The region is uppercase, the language is lowercase. - x-default —
hreflang="x-default"is the fallback page when no language match is found. Almost always the international or "choose your language" page.
The three implementation methods
Google accepts hreflang in three places — pick exactly one per site, never mix:
- HTML
<link>tags in<head>— the default for most CMS-driven sites. Easy to debug. - HTTP
Linkheader — required for non-HTML files like PDFs, where you cannot add a<link>tag. Set by your web server (nginx, Apache). - XML sitemap with
<xhtml:link>entries — best for large sites (1000+ URLs) because all variants of all pages live in one file Google crawls efficiently.
Most common language and region codes
| Language (ISO 639-1) | Region (ISO 3166-1) | Locale example |
|---|---|---|
| en (English) | US, GB, CA, AU, IN, IE, NZ, ZA | en-US, en-GB, en-AU |
| es (Spanish) | ES, MX, AR, CO, CL, PE | es-ES, es-MX, es-AR |
| fr (French) | FR, CA, BE, CH, LU | fr-FR, fr-CA, fr-BE |
| de (German) | DE, AT, CH | de-DE, de-AT, de-CH |
| pt (Portuguese) | PT, BR | pt-PT, pt-BR |
| zh (Chinese) | CN, TW, HK, SG | zh-CN, zh-TW, zh-HK |
| ar (Arabic) | SA, AE, EG, MA | ar-SA, ar-AE |
| nl (Dutch) | NL, BE | nl-NL, nl-BE |
| ru (Russian) | RU, BY, KZ, UA | ru-RU, ru-KZ |
The three hreflang rules Google enforces
- 1. Self-reference is required — every page must list itself in its own hreflang block. If
/en/declares 4 variants, one of them must be/en/. - 2. Reciprocity is required — if
/en/links to/fr/as the French variant, then/fr/must link back to/en/as the English variant. Google ignores broken pairs. - 3. Absolute URLs are required — relative URLs like
/fr/aboutare not supported. Always use the fullhttps://…form.
Common mistakes to avoid
- Using a country code as a language code —
hreflang="uk"means Ukrainian, not "UK English". The correct code for British English isen-GB. - Mixing methods — never use HTML link tags AND XML sitemap entries for the same pages; pick one source of truth.
- Pointing to non-canonical URLs — every hreflang URL should also be the canonical for that page, never a 301-redirected URL.
- Forgetting x-default — without it, users in unlisted languages get a randomly chosen variant. Always include it.
- Wrong region case — language is lowercase, region is uppercase.
fr-FRnotFR-frorfr-fr.
Use cases
- E-commerce localised stores — same product in multiple countries with different currencies and stock.
- SaaS landing pages — homepage translated into the company's main markets.
- News & publishing — multilingual content sites (Wikipedia-style) with full translations of every article.
- Documentation portals — technical docs available in multiple languages, often with country-specific examples.
- Government & institutional sites — official content available in all national languages (EU, Canada, Switzerland).
Frequently Asked Questions
The HTML lang attribute (e.g. <html lang="en">) tells the browser and screen readers what language the current page is written in. The hreflang attribute on <link rel="alternate"> tells search engines which other URLs are translations of the current page. They serve different purposes and you should use both.
Strongly recommended. Without it, users whose browser language doesn't match any of your declared variants are shown a random variant chosen by Google. The x-default page is usually the international or "choose your language" landing page, but can also point to your main version (e.g. the English page).
No. The generator runs entirely in your browser — language codes, URLs and the generated tags are computed locally and nothing is uploaded. Safe to use with unpublished staging URLs.
Inside the <head> element. Each page (including the original) must list every variant including itself. Order doesn't matter to search engines but keeping them in a stable order makes them easier to maintain.
For large sites (typically 1000+ URLs) the XML sitemap form is more efficient: all variants of all URLs live in a single file Google crawls in one pass, and you don't need to render the link block on every HTML response. The trade-off is harder debugging because the tags are not visible in page source.
No. Each URL should serve a single language and locale. If the same URL renders different content for different users (e.g. via cookies or IP geolocation), hreflang cannot be used reliably — Google needs one URL per variant. Refactor to use distinct paths (/en/, /fr/) or subdomains (en.example.com) first.
Hreflang is supported by Google and Yandex. Bing uses a different signal — the content-language HTTP header and the page lang attribute — and ignores hreflang. For Bing-heavy markets you may want to set both.
No. The syntax requires a language code, and the region is optional after it. hreflang="US" is invalid; use en-US instead.