Hreflang
An HTML attribute that tells search engines which language and region versions of a page are available.
Hreflang is an HTML attribute (rel="alternate" hreflang="x") that informs search engines about the language and region versions of a page. It prevents the wrong language version from appearing in search results and protects against duplicate content issues on multilingual websites.
Implementation methods
Hreflang can be implemented via HTML link tags in the <head>, via HTTP headers, or in the XML sitemap — bibliotheekterm. Each method has pros and cons; the sitemap method scales best for large websites.
Common mistakes
The most common mistake is missing return tags: if page A references page B, B must also reference A. Other mistakes: using wrong language codes, not combining hreflang with canonical tags, and inconsistent URLs.
Code example: NL/EN site
<!-- On the Dutch page (https://example.com/nl/over-ons/) -->
<head>
<link rel="canonical" href="https://example.com/nl/over-ons/" />
<link rel="alternate" hreflang="nl" href="https://example.com/nl/over-ons/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/about-us/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en/about-us/" />
</head>
<!-- On the English page (https://example.com/en/about-us/) -->
<head>
<link rel="canonical" href="https://example.com/en/about-us/" />
<link rel="alternate" hreflang="nl" href="https://example.com/nl/over-ons/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/about-us/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en/about-us/" />
</head>
Hreflang in XML Sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/nl/over-ons/</loc>
<xhtml:link rel="alternate" hreflang="nl" href="https://example.com/nl/over-ons/" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/about-us/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/en/about-us/" />
</url>
<url>
<loc>https://example.com/en/about-us/</loc>
<xhtml:link rel="alternate" hreflang="nl" href="https://example.com/nl/over-ons/" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/about-us/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/en/about-us/" />
</url>
</urlset>
Language codes reference table
| Language code | Language | With region (example) | When to use region |
|---|---|---|---|
| nl | Dutch | nl-BE (Belgian Dutch) | When you have separate content for NL and BE |
| en | English | en-US, en-GB | When you have separate content for US and UK |
| de | German | de-AT, de-CH | When you have separate content for Germany, Austria, or Switzerland |
| fr | French | fr-BE, fr-CA | When you have separate content for France, Belgium, or Canada |
| es | Spanish | es-MX, es-AR | When you have separate content for Spain vs Latin America |
| pt | Portuguese | pt-BR | When you have separate content for Portugal and Brazil |
| it | Italian | it-IT | Rarely needed, unless Swiss variant |
| ja | Japanese | ja-JP | Region is rarely needed |
| zh | Chinese | zh-CN, zh-TW | Simplified (CN) vs Traditional (TW) |
| x-default | Default/fallback | n/a | Always include: points to the default version for unmatched languages |
Common mistakes
- Missing return tags: if the NL page references the EN page, EN must also reference NL. Missing return tags cause Google to ignore the entire hreflang set.
- Wrong language codes: use ISO 639-1 language codes (two letters).
hreflang="nl-NL"is valid, buthreflang="dutch"orhreflang="ned"is not. - Forgetting x-default: the x-default tag tells Google which page to show when no language version matches. Without x-default, Google chooses on its own, which may result in the wrong language version.
- Inconsistent URLs: if your hreflang references
https://example.com/nl/but the canonical for that page ishttps://www.example.com/nl/, a conflict arises. - Mixing canonical and hreflang: each language version must have a self-referencing canonical. A canonical that cross-references languages (NL canonical pointing to EN) is incorrect.
- Hreflang on noindexed pages: if a page has a noindex tag, Google ignores the hreflang annotation. Ensure all pages in an hreflang set are indexable.
Frequently asked questions
What's the difference between hreflang and the lang attribute?
The lang attribute on the <html> element tells browsers which language the page content is in (for accessibility and speech synthesis). Hreflang tells search engines which alternative language versions are available. Both are needed but serve different purposes.
Should I use hreflang if I only have two languages?
Yes, hreflang is important even with just two languages. Without hreflang, Google might show the Dutch version to English-speaking users and vice versa. Hreflang ensures the right version is shown to the right user.
Does hreflang work with Bing?
Bing supports hreflang but prefers the content-language HTTP header and meta tag. For optimal compatibility, you can implement both.
How do I test if my hreflang is correct?
Use tools like Ahrefs Site Audit, Screaming Frog, or the free Hreflang Tags Testing Tool by Merkle. Specifically check for missing return tags, wrong language codes, and inconsistent URLs.
Can I combine hreflang with subdomains or separate domains?
Yes. Hreflang works with subfolders (/nl/, /en/), subdomains (nl.example.com), and even separate domains (example.nl, example.com). The URLs just need to be consistent and accessible.
What does our scanner check?
Our scanner checks whether your page has a correct lang attribute on the <html> element, indicating that you're deliberately managing language settings. This is the foundation for correct hreflang implementation and helps both browsers and AI bots recognize your content's language. Test your language configuration.