When a site exists in more than one language, or targets more than one country, search engines have to decide which version to serve to which user. Hreflang is the signal that makes that decision explicit: a set of annotations mapping every equivalent page to its language and, optionally, its region.
Each annotation names a language — and optionally a region — with a code such as en, en-GB or de-AT, and points to the matching URL. The annotations can live in one of three places: in the page head as link elements, in the HTTP header (useful for non-HTML files), or inside the XML sitemap. Pick one method and apply it consistently — mixing them creates conflicts.
Hreflang only works when it is reciprocal: if your English page points to the German one, the German page must point back, and every page in the set should also reference itself. A special value, x-default, tells engines which version to fall back to when no language or region matches — usually an international or language-selector page.
Hreflang and the canonical tag solve different problems and must agree. A canonical says “this is the primary version of duplicate content”; hreflang says “these are equivalent versions for different audiences.” Each language version should be self-canonical — pointing its canonical at itself — while hreflang links the set together. Canonicalising every language version to a single URL is a common mistake that quietly removes the others from the markets they were built for.
None of this fixes a messy structure. Hreflang is a label on top of a deliberate international architecture — a clear choice of subdirectories, subdomains or country domains, consistent URL patterns, and no gaps where a version is declared but missing. Get the architecture right first; the most common hreflang failures are missing return links, wrong or invented language codes, and pointing at URLs that redirect or fail to resolve.
FAQ
Frequently asked questions
Any of the three works, but use only one. Link elements in the page head are the most common and easiest to debug; the XML sitemap keeps the markup off the page and scales well for large sites; the HTTP header is mainly for non-HTML files like PDFs. What matters is consistency, and that every annotation is reciprocal and points to a live, self-canonical URL.
x-default is the fallback. It tells search engines which version to show when none of the declared language or region versions match the user. It usually points to an international homepage, a language-selector page, or your primary-language version.
Yes — they do different jobs. A canonical resolves duplicate content to one primary URL; hreflang connects genuinely different language or regional versions that should all stay indexed. Each language version should be self-canonical, and hreflang links them as a set. If you canonicalise every version to a single URL, you effectively hide the rest from their target markets.