TECHNICAL SEO 5 min read

Hreflang

An HTML attribute that tells search engines which language and region versions of a page are available.

Bas Vermeer
Bas Vermeer SEO/AEO Specialist

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 codeLanguageWith region (example)When to use region
nlDutchnl-BE (Belgian Dutch)When you have separate content for NL and BE
enEnglishen-US, en-GBWhen you have separate content for US and UK
deGermande-AT, de-CHWhen you have separate content for Germany, Austria, or Switzerland
frFrenchfr-BE, fr-CAWhen you have separate content for France, Belgium, or Canada
esSpanishes-MX, es-ARWhen you have separate content for Spain vs Latin America
ptPortuguesept-BRWhen you have separate content for Portugal and Brazil
itItalianit-ITRarely needed, unless Swiss variant
jaJapaneseja-JPRegion is rarely needed
zhChinesezh-CN, zh-TWSimplified (CN) vs Traditional (TW)
x-defaultDefault/fallbackn/aAlways 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, but hreflang="dutch" or hreflang="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 is https://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.

RELATED TERMS

SEO

Search Engine Optimization: the set of techniques to improve a website's ranking in search engines.

Bas Vermeer Bas Vermeer

Indexing

The storing and cataloging of web content by search engines so it becomes findable.

Bas Vermeer Bas Vermeer

Canonical URL

An HTML tag that tells search engines which version of a page is the original when duplicate content exists.

Bas Vermeer Bas Vermeer

RELATED SCANNER CHECKS

HTML lang attribute

RELATED ARTICLES

Bas Vermeer
Bas Vermeer

SEO/AEO Specialist

My career started by manually combing through server log files. I wanted to understand how Googlebot crawls websites. That fascination with the technical side of discoverability? Never faded. At Koba...