Hreflang Tag Generator
Build hreflang tags for any international setup
Dynamic row builder with BCP 47 inline validation, 5 presets, and output in HTML, XML sitemap, and HTTP header formats. The UK→GB trap is flagged automatically.
<link rel="alternate" hreflang="en" href="https://example.com/" />
<head> section of every page in the hreflang set.Already have hreflang implemented?
Run 18 automated checks — invalid codes, missing return tags, noindex conflicts, html lang mismatches. → Hreflang Checker
Common BCP 47 Mistakes
These are the most common hreflang code errors that cause Google to silently discard your tags.
| Wrong | Correct | Why |
|---|---|---|
en-UK | en-GB | UK is not a valid ISO 3166-1 code. The United Kingdom's code is GB (Great Britain). |
EN | en | Language codes must be lowercase per BCP 47. EN is silently ignored. |
en-us | en-US | Region codes must be uppercase. en-us will not work correctly. |
en-USA | en-US | ISO 3166-1 Alpha 2 is exactly 2 letters. USA is the 3-letter Alpha 3 code. |
ENG | en | ENG is the ISO 639-2 three-letter code. Hreflang requires ISO 639-1 two-letter codes. |
zh-CN | zh-CN | ✓ Correct. Chinese Simplified for mainland China. |
zh-TW | zh-TW | ✓ Correct. Chinese Traditional for Taiwan. |
Three Ways to Implement Hreflang
All three methods are accepted by Google — choose the one that fits your infrastructure.
HTML link tags
Most commonAdd <link rel="alternate" hreflang="..."> tags to the <head> section of every page in the hreflang set. Simple to implement but requires updating every page's HTML when you add a new language.
XML sitemap
Best for large sitesAdd xhtml:link elements inside each <url> block in your XML sitemap. Preferred for large sites because you only update one file. Requires xmlns:xhtml namespace in the urlset element.
HTTP headers
For non-HTML filesInject Link headers via your web server for PDF documents and other non-HTML files that cannot contain <head> markup. Requires server configuration access.
Google's Hreflang Rules
Breaking any of these rules may cause Google to ignore your entire hreflang set without warning.
Every page must reference itself
Each page in the hreflang set must include a self-referencing tag — a hreflang link pointing back to its own URL. Missing self-references are a common error.
Bidirectional return tags are required
If page A references page B in its hreflang set, page B must also reference page A. Missing return tags are the most commonly broken rule and can cause Google to ignore the entire set.
Tags must appear on every page in the set
The complete set of hreflang tags must appear on every page — not just on the homepage or a central page. Every language version must carry the full tag set.
Use absolute URLs only
Hreflang href values must be fully qualified absolute URLs including the protocol (https://). Relative paths like /de/page/ are not valid.
Each hreflang code must be unique
The same hreflang value cannot appear more than once in a set. Duplicate codes may cause Google to ignore the entire implementation.
Frequently Asked Questions
What is the hreflang attribute?
Hreflang is an HTML attribute that tells Google which language and region a specific page is intended for, and which alternative pages exist for other language or region variants. It helps Google serve the correct version of your content to users in different countries or who speak different languages.
Why is 'UK' wrong in hreflang?
UK is not a valid ISO 3166-1 Alpha 2 region code. The correct code for the United Kingdom is GB (Great Britain). Using hreflang='en-UK' will be silently ignored by Google — the correct tag is hreflang='en-GB'. This is the most common hreflang implementation mistake.
What is x-default in hreflang?
x-default is a special hreflang value that designates a fallback page for users whose language or region is not explicitly covered by any other hreflang tag. It is recommended to always include an x-default tag, typically pointing to your homepage or language selector page.
Does every page in the hreflang set need all the tags?
Yes. Every page in the hreflang set must contain the complete set of hreflang tags. Your German page must also have tags pointing to the English and French versions, and vice versa. Missing return tags may cause Google to ignore the entire set.
What is the difference between HTML link tags and XML sitemap hreflang?
Both tell Google about your hreflang setup — the end result is the same. HTML link tags go into the head of each page. XML sitemap hreflang is often preferred for large sites because you only update one file rather than every page's HTML.
