A site translated into several languages, or tailored by country within the same language (United States, United Kingdom, Canada…), offers several versions of the same page. Without any hint, Google may show the English version to a French speaker, or treat nearly identical regional variants as duplicates. The hreflang attribute connects these versions and states the language, and optionally the region, of each one. The search engine can then show the right version in each user's search results.
The syntax
<link rel="alternate" hreflang="fr" href="https://example.com/fr/guide/">
<link rel="alternate" hreflang="en" href="https://example.com/en/guide/">
<link rel="alternate" hreflang="fr-CA" href="https://example.com/ca/guide/">
<link rel="alternate" hreflang="x-default" href="https://example.com/en/guide/">
- The value combines a two-letter language code (ISO 639-1) and, if needed, a country code (ISO 3166-1 alpha-2):
en,en-US,en-GB. A country code on its own is not valid:bemeans Belarusian, not Belgium. - The
x-defaultvalue designates the page to show when no language matches, for example a language selector or the international version. - URLs must be fully qualified, including the protocol and domain.
Google accepts three equivalent placements: <link> elements in the HTML head, an HTTP Link header (handy for PDFs), or entries in the XML sitemap. One is enough; on a large site, the sitemap is often the easiest to maintain.
The reciprocity rule
Each version must list every other version and itself. If the French page declares an English version but the English page doesn't link back to the French one, Google ignores these annotations. This is the most common source of errors, especially when a translation is added or removed without updating the other pages.

Common mistakes
- Non-reciprocal links, or links pointing to redirected pages, 404 errors or
noindexpages. - Hreflang that contradicts canonicals: each version must have its own canonical URL, pointing to itself, not to the main version.
- Made-up codes:
en-UKinstead ofen-GB, oren-US-texas. - Relying on hreflang to signal the language: Google states that it uses neither hreflang nor the HTML
langattribute to detect a page's language. The text itself is what counts, hence the importance of real translations rather than half-translated pages. - Automatically redirecting based on the browser language: a crawler working from a single country may never see some versions. Offer a language switcher instead.
Properly tagged regional variants also keep them from being treated as competing duplicate content.
For WordPress
WordPress doesn't support multilingual sites natively, and therefore doesn't output hreflang tags. Multilingual plugins take care of it: Polylang, for example, automatically adds hreflang tags between linked translations, but only generates x-default for the home page, in certain configurations. WPML and other solutions have their own settings. In every case, check the source code of a few pages and the Search Console report after adding a language, and avoid stacking an SEO plugin and a multilingual plugin that would each output their own tags.