Hreflang is an HTML attribute (rel='alternate' hreflang='language-country') that tells search engines which language and regional version of a page to show to users based on their location and language settings. A UK website with versions in English (en-GB), French (fr-FR), and German (de-DE) uses hreflang to ensure UK users see the English version, French users see the French version, and German users see the German version. Without hreflang, Google may show the wrong language version to users — or treat the multiple versions as duplicate content.
Hreflang implementation is one of the most technically complex areas of SEO, with many opportunities for error. The most common mistakes include hreflang annotations that are not mutual (all versions must reference all other versions), missing x-default hreflang (for users not matching any specific language/country combination), incorrect language-country code combinations, and hreflang implementation via JavaScript (which is slower to process than server-rendered HTML or HTTP header implementation).
Hreflang implementation approaches
- HTML head tag — the most common method; add hreflang link elements in the page <head>
- XML sitemap — declare all language variants in the sitemap; efficient for large sites
- HTTP headers — for PDFs and non-HTML files where head tags are not possible
- All versions must reference all others — each language page must link to all other language versions and to itself
- Use correct language codes — ISO 639-1 two-letter language codes (en, fr, de, es) with optional ISO 3166-1 country codes
- Include x-default — for pages that should appear when no language/country matches the user's settings
- Use absolute URLs — always use full URLs including https:// in hreflang values
UK-only English websites (targeting en-GB only) do not need hreflang unless they also have content in other languages or target specific countries within the English-speaking world distinctly (en-GB for UK, en-US for USA, en-AU for Australia). A UK business that has separate site versions for different English-speaking markets benefits from hreflang to ensure the correct version is served. A UK business serving only UK customers in English does not need hreflang.
The x-default hreflang annotation designates a 'default' page for users who do not match any specific language/country combination. For example, if a site has en-GB, fr-FR, and de-DE versions, and a Spanish user visits, there is no matching version. The x-default hreflang tells Google which page to show in this fallback scenario — typically the English (en) or global homepage. x-default is considered best practice to include whenever hreflang is implemented.