hreflang
An attribute for specifying language and regional versions of a page. A key element of international SEO that prevents duplicate content.
hreflang is an attribute of the `link` tag (or HTTP header, or sitemap element) that tells search engines about alternative versions of a page in different languages or for different regions. Thanks to hreflang, Google shows the most appropriate version to the user.
What is hreflang
hreflang is used for multilingual and multi‑regional websites. It addresses duplicate content issues (same information in different languages) and helps Google choose the correct version for the user based on language and location.
Syntax and codes
<link rel="alternate" hreflang="ru" href="https://example.com/ru/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />Codes: language – ISO 639-1 (ru, en, de). Language+region – ISO 639-1 + ISO 3166-1 (en-US, en-GB, pt-BR). x-default points to the fallback version when no language/region matches.
Implementation methods
- HTML link in
<head>‑ the most common method for regular pages. - HTTP headers – for non‑HTML files (PDF, images, etc.).
- Sitemap – convenient for large sites where adding annotations to each page manually is heavy.
Example in sitemap.xml:
<url>
<loc>https://example.com/ru/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/" />
<xhtml:link rel="alternate" hreflang="ru" href="https://example.com/ru/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/" />
</url>Common errors when using hreflang
- Missing self‑referencing (the page must point to itself)
- No
x-default - Incorrect language codes (e.g.,
rusinstead ofru) - Relative URLs (absolute URLs with https:// required)
- Asymmetric links (page A links to B, but B does not link back to A)
Common questions
x-default to specify the version for users whose language or region is not covered by other annotations.Discuss your project?
Share your goals and website context — I will suggest a practical next step.