Quick answer
Hreflang is an annotation that connects the language and regional versions of a page so search engines can show each searcher the right one. Every version lists all versions, itself included, as language or language-region codes with full URLs, in HTML, HTTP headers or a sitemap.
What is hreflang?
Hreflang is an annotation that connects the language and regional versions of one page, so that a search engine can show a searcher the version meant for them. Each annotation has two parts: a language code, optionally with a region, and the full URL of that version. A German page, its English twin and its Japanese twin each carry the same list.
The word comes from the hreflang attribute on web links, which is a hint about the language of the page being linked to. In search engine work it almost always means the combination rel="alternate" plus hreflang, as described in Google's documentation on localized versions.
Two limits are worth knowing first. Hreflang does not translate anything, and Google does not use it, or the HTML lang attribute, to detect what language a page is written in. It only tells Google which pages belong together and who each one is for.
Hreflang syntax and language codes
The basic element goes in the <head>:
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/pricing" />
The value is a language code from ISO 639-1, optionally followed by a region code from ISO 3166-1 alpha-2, joined by a hyphen. A script code from ISO 15924 can be written for Chinese. Google reads the value without regard to case, though regions are conventionally upper case. The URL must be fully qualified, including https://.
| Value | Valid for Google? | Meaning or problem |
|---|---|---|
en | Yes | English, any region |
en-GB | Yes | English for users in the United Kingdom |
de-CH | Yes | German for users in Switzerland |
zh-Hans | Yes | Chinese in simplified script |
zh-Hans-US | Yes | Simplified Chinese for users in the United States |
x-default | Yes | Fallback when no listed language or region matches |
en-UK | Region ignored | UK is a reserved code; the United Kingdom is GB |
jp | No | jp is a country code; the Japanese language is ja |
be alone | Wrong target | be is the Belarusian language, not Belgium |
US alone | No | A region cannot be given without a language |
es-419 | No | Numeric regional codes are not supported |
Belgium shows why the order matters: nl-BE, fr-BE and de-BE are three audiences in one country.
The reciprocal rule and self-reference
Google states two requirements for every method. Each language version must list itself as well as all other versions. And if two pages do not point to each other, the tags are ignored. The second rule stops a stranger from declaring their page to be the French version of yours.
Sample data: a pricing page exists in English, German, French and Japanese. A crawl returns these annotations:
| Page | Lists en | Lists de | Lists fr | Lists ja |
|---|---|---|---|---|
| en | Yes (self) | Yes | Yes | Yes |
| de | Yes | Yes (self) | Yes | Yes |
| fr | Yes | Yes | No (self missing) | No |
| ja | Yes | Yes | Yes | Yes (self) |
Four versions form 4 × 3 ÷ 2 = 6 pairs. Five pairs link in both directions: en–de, en–fr, en–ja, de–fr and de–ja. The pair fr–ja fails, because Japanese points to French but French does not point back. The French page also leaves itself out. Both errors sit in one template, so the fix is to generate the same complete list for all four pages from one table of URLs.
If keeping a full set across many languages gets hard, Google says you may omit some languages on some pages, and the pairs that do point to each other are still processed. Link new language versions both ways with your main language first.
What is x-default?
x-default is a reserved value for the page to use when a searcher's language settings match none of your versions:
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing" />
Google says it was designed for language selector pages and works best with them, although any page can carry it. The same URL may appear twice in a set, for instance as both en and x-default, when the English page is your fallback. It needs no language code of its own.
A rule for picking it: if you have a page where visitors choose a country or language, point x-default there. If you do not, point it at the version a stranger is most likely to be able to use. If you serve several regions in one language, such as en-IE, en-CA and en-AU, Google also advises a generic en page for everyone else who reads English.
Three ways to implement hreflang
Google treats three methods as equivalent. Pick one; using several brings no benefit in Search and is harder to keep consistent.
| Method | Where | Best for | Cost |
|---|---|---|---|
HTML <link> elements | <head> of every version | Small sites, CMS templates | Every page grows with each new language |
HTTP Link header | Server response | PDF and other non-HTML files | Needs server configuration; invisible in page source |
XML sitemap with xhtml:link | Sitemap file | Large sites, many languages | A build step must keep the file complete |
A header version for a PDF looks like this:
Link: <https://example.com/guide.pdf>; rel="alternate"; hreflang="en",
<https://example.com/de/guide.pdf>; rel="alternate"; hreflang="de"
In a sitemap, add the namespace xmlns:xhtml="http://www.w3.org/1999/xhtml", create one <url> entry per URL, and give each entry the full list, itself included:
<url>
<loc>https://example.com/de/pricing</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/pricing"/>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/pricing"/>
</url>
The English URL then gets its own entry with the same two child lines.
Worked example: how big does a six-version site get?
Sample data: 1,200 pages, each published in six language versions, plus an x-default annotation.
| Quantity | Calculation | Result |
|---|---|---|
| URLs | 1,200 × 6 | 7,200 |
| Annotations per URL | 6 versions + x-default | 7 |
| Annotations in total | 7,200 × 7 | 50,400 |
| Version pairs that must link both ways, per page | 6 × 5 ÷ 2 | 15 |
| Pairs across the site | 1,200 × 15 | 18,000 |
| Sitemap size at about 101 bytes per annotation line plus the URL entries | computed on sample URLs | about 5.7 MB uncompressed |
The sitemap protocol allows 50,000 URLs and 50 MB (52,428,800 bytes) uncompressed per file. Google notes that the xhtml:link children do not count toward the URL limit, so these 7,200 entries fit in one file, although splitting by section makes errors easier to locate. In HTML, the same site adds 7 lines to each head, about 650 bytes at this URL length. With 30 languages plus x-default it would be 31 lines on every page, which is the point where many teams move to the sitemap.
The 18,000 pairs also explain why hand editing fails: one language template that leaves out one other language breaks 1,200 pairs at once.
How to validate hreflang: a checklist
Work through these in order, on a sample of templates rather than random pages:
- Self-reference. Every version lists its own URL.
- Return links. For every A → B there is a B → A.
- Codes. Language from ISO 639-1, region from ISO 3166-1 alpha-2; no
UK,EUorUN. - Full URLs. Scheme and host included, no relative paths.
- Targets. Each URL returns 200, is allowed to be indexed and is not a redirect.
- Canonicals. Each version's canonical is in its own language. A German page that declares the English URL as canonical sends a contradictory signal.
- Placement. Elements sit inside a well-formed
<head>, andhreflangis not combined with amediaattribute in one tag. - One method. HTML, header or sitemap, not a mixture that can disagree.
- Fallback.
x-defaultexists where visitors with other languages need a landing place.
To see what one page sends, run curl -s URL | grep -o '<link[^>]*hreflang[^>]*>' for HTML and curl -sI URL | grep -i '^link:' for headers. A site-wide check needs a crawler that stores every annotation and then joins the pairs, as in the four-language table above.
Hreflang vs canonical vs the lang attribute
| Hreflang | rel="canonical" | lang attribute | |
|---|---|---|---|
| Question it answers | Which versions belong together, and for whom? | Which of several copies is preferred? | What language is this content? |
| Relationship | Many pages, all listing each other | Duplicates pointing at one target | Describes a document or element |
| Read by | Search engines, for choosing a version | Search engines, for choosing a representative | Browsers and assistive technology |
| Typical error | Missing return link | Translation pointing at the original language | Left at the template default |
Hreflang and canonical work together when each language version names itself as canonical and lists the others as alternates. Google counts localized versions as duplicates only when the main content stays untranslated, for example a translated menu around the same English body. For URL structure, localization and a full audit of a three-language site, see multilingual SEO.
Hreflang and visitor data in TapCub
Hreflang itself is checked with a crawler and Search Console; TapCub does not read or validate the tags. What it can show is whether people end up on the version meant for them. Suppose the French template above is fixed.
- Group the versions. In Web analytics › Pages, use Page groups with a prefix rule for each language folder, such as
/fr/, to see pageviews and bounce rate per version. - Compare language and country. Web analytics › Audience breaks visitors down by country and browser language. To see which version one country reaches, click that country in the geography list on Web analytics › Overview; the page list on the same screen is then filtered to it.
- Check search. With Google Search Console connected, Monitoring › Search performance splits clicks, impressions and position by page, query and country, usually one to three days late. Impressions from France that keep going to an English URL point back to a broken pair.
- Mark the release. Add a date note in Configuration › Annotations so that the before and after periods are easy to separate.
Sources
- Google Search Central, Tell Google about localized versions of your page. Checked 2026-12-03.
- IETF, RFC 8288: Web Linking, section 3.4, October 2017: the
hreflangtarget attribute. - sitemaps.org, Sitemaps XML format: per-file URL and size limits. Checked 2026-12-03.
- Library of Congress, ISO 639-2 and ISO 639-1 language code list. Checked 2026-12-03.
- MDN Web Docs, lang global attribute. Checked 2026-12-03.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Data Engineer
Writes about event design, data quality, and collection workflows, with verifiable implementation methods for reliable analytics.