How Hreflang works
Hreflang can be declared in the page head, in HTTP headers or in the XML sitemap. A site serving India in English and Hindi, the UK, the US, and Canada in English and French would mark up en-IN, hi-IN, en-GB, en-US, en-CA and fr-CA versions, each page listing all six including itself, plus an x-default for everyone else. Language codes follow ISO 639-1 and regions ISO 3166-1 alpha-2, which is why en-UK is invalid: the region code is GB.
The links must be reciprocal. If the en-GB page points to en-US but en-US does not point back, search engines may ignore the pair. Each URL should also be the canonical of its own version; canonicalising every regional page to the US page tells engines to drop the others and defeats hreflang. Google treats hreflang as a signal rather than a directive, and other engines weigh language signals differently, so set the html lang attribute too.
Hreflang does not translate pages, does not improve rankings on its own, and is unnecessary for a site in one language serving one market. Local prices, spelling and contact details give each regional version a real reason to exist.
How to improve it
- 01Map every page to its language and region versions before writing any markup.
- 02Use valid codes: en-GB rather than en-UK, and a language code alone, such as fr, when one page serves all speakers of a language.
- 03Make every set reciprocal and self-referencing, and add x-default.
- 04Keep each regional URL self-canonical, never canonicalised to another market's version.
- 05Localise more than language: currency, spelling, contact details and legal notes.
- 06Generate hreflang from the template or sitemap rather than by hand, and recheck it after site changes.
A fictional online tutoring company expands from the US into the UK and Canada by copying its US pages, and Canadian searchers keep seeing US prices. It publishes en-US, en-GB, en-CA and fr-CA versions with local currency and spelling, lists all four on every page with an x-default pointing to a country chooser, and stops canonicalising everything to the US page.