hreflang is an HTML annotation that tells search engines which language and region a page is meant for, so they can show the right version to the right user. If your site exists in several languages, hreflang is what stops Google from showing a French visitor your English page — or treating your translated pages as duplicate content.
Why hreflang matters
Without hreflang, search engines have to guess which version of a page to rank and show for a given user. That leads to two problems: the wrong-language page showing up in results (hurting clicks and bounce rate), and multiple language versions competing with each other. hreflang resolves both by explicitly linking the versions and labelling each one's audience.
What an hreflang tag looks like
Each annotation is a <link> in the page <head>:
<link rel="alternate" hreflang="de" href="https://example.com/de/" />
It has three parts: rel="alternate" (this is an alternate version), hreflang="de" (the language, optionally a region), and href (the URL of that version). You can generate a full set with the free hreflang generator.
The value: language and (optional) region
The hreflang value is an ISO 639-1 language code, optionally a hyphen and an ISO 3166-1 region: en, en-GB, pt-BR. Use a bare language code unless you genuinely have different content per region. See the full language-code reference.
x-default: the fallback
A special value, x-default, tells search engines which page to show users who don't match any of your specific versions. It usually points at your homepage or a language selector:
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
The golden rule: reciprocity
hreflang only works if it's reciprocal. If page A references page B, then page B must reference page A back — and each page should also reference itself. If the links aren't mutual, Google ignores the whole annotation. This is the single most common reason hreflang "doesn't work." Verify it with the hreflang checker.
Where hreflang can live
- In the HTML
<head>— the most common method, and what most WordPress plugins use. - In HTTP headers — useful for non-HTML files like PDFs.
- In the XML sitemap — an alternative for large sites, using
<xhtml:link>alternates.
Pick one method per page — don't mix and duplicate.
Common mistakes
- Non-reciprocal links — the number-one error (see above).
- Invalid codes —
en-UKinstead ofen-GB, or using a country code as a language. - Missing self-reference — each page must list itself.
- Missing x-default — no fallback for unmatched users.
- Wrong or relative URLs — use absolute, canonical, indexable URLs.
Do you have to do this by hand?
No — and on a real site you shouldn't. Maintaining reciprocal hreflang across every page and language by hand is where errors creep in. A translation plugin like Gloty generates correct, reciprocal hreflang (with x-default), per-language canonicals, and translated meta automatically. For the setup steps, see how to add hreflang in WordPress.