hreflang
Definition
An hreflang annotation names a target audience and the URL that serves it. There are three places to put it, and you pick one rather than mixing them: link elements with rel="alternate" in the head of each page, a Link HTTP response header for files with no head such as a PDF, or xhtml:link entries inside sitemap.xml, which is the tidiest option for a large set. The value is an ISO 639-1 language code, optionally followed by a hyphen and an ISO 3166-1 Alpha-2 region code, so 'en', 'en-gb', 'pt-br' and 'de-at' are all valid. A region on its own is not: 'gb' is read as a language code and is simply wrong. The reserved value 'x-default' marks the page to use when nothing else fits, typically a language selector or the international version.
Why It Matters
Without it, a set of translations often reads as near-duplicate content, and the engine picks one version to show everyone — so a reader in Munich gets the American page and bounces. With it, the engine keeps all the versions in the index and swaps in the appropriate one for each searcher. The cost of getting it wrong is subtle rather than dramatic: nothing is penalised, the annotations are simply ignored, and you are back to where you started while believing you have solved it. It is also worth being clear about scope. hreflang is a targeting signal, not a ranking boost and not a substitute for actually translating the content.
How It Works
The critical rule is that the annotations must be reciprocal. Every page in a language set lists every other page in that set, including a self-referential entry pointing at itself, and if page A claims page B without page B claiming A back, the pair is discarded — one broken return link can invalidate a whole cluster. Each version should also carry a canonical URL pointing at itself, never at another language, because a cross-language canonical tells the engine to drop the page you were trying to promote. The codes must also be correct: 'en-uk' is a common error, since the country code for the United Kingdom is GB. Google is the main consumer of hreflang, and other engines treat it with varying interest.
Real-World Example
A studio publishes a product one-pager three times on 99helpers — nordvik-en.99helpers.site, nordvik-de.99helpers.site and nordvik-fr.99helpers.site — with the same layout and translated copy. Each page carries four link elements in its head: one for each language plus an x-default pointing at the English version. German searchers then land on the German address instead of the English one.
Common Mistakes
- ✕Leaving out the self-referential entry — a page that does not list itself breaks the reciprocity check for the whole set
- ✕Writing 'en-uk' for the United Kingdom — the ISO 3166-1 code is GB, and an invalid region silently voids the annotation
- ✕Pointing each translation's canonical at the English version — that asks the engine to drop the very pages you are annotating
- ✕Using hreflang to separate two pages of identical English text for different countries with no real difference — there is nothing for the engine to choose between
Related Terms
Duplicate Content
Duplicate content is substantially the same text reachable at more than one URL, on a single site or across sites. It is a consolidation problem, not a penalty.
Canonical URL
A canonical URL is the one address you nominate as the real home of a piece of content when several addresses serve it. You declare it with a rel=canonical link in the page head, and search engines use it to decide which version to index.
Language Attribute
The language attribute declares what human language a page or a passage is written in, using lang on an HTML element. It tells software how to pronounce the words, which most readers never notice until it is wrong.
sitemap.xml
An XML file listing the pages of a site so search engines do not have to find them all by following links. It aids discovery; it does not affect ranking.
URL Structure
URL structure is how the address of a page is put together — the words in the path, the separators between them, and how many levels deep the page sits.
Put a file online in seconds
Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.
Host a file free →