Webmaster Bench

Tools / hreflang Checker & Generator

hreflang Checker & Generator

Paste the hreflang tags of one page, or of several pages each headed by its own URL, to check codes and return links. Or list your language versions and generate the tags.

Accepts <link> tags, sitemap <xhtml:link> lines, Link: headers, or simple "code URL" lines. Put each page's own URL on a line by itself above its tags to check return links.

What hreflang does

hreflang tells search engines that several URLs are the same content for different languages or regions, so they can show each searcher the right version: the German page to German speakers, the UK English page to people in the United Kingdom. It does not move rankings between versions and is not a redirect; it only swaps which version appears for a given searcher. Google and Yandex use it; Bing relies mainly on the content-language meta tag and lang attribute instead.

The four rules that break most implementations

  1. Valid codes. The value is an ISO 639-1 language code, optionally followed by an ISO 3166-1 alpha-2 country code: en, en-GB, pt-BR. A script (ISO 15924) may sit in between: zh-Hant, zh-Hant-TW. A country alone is not allowed. Classic mistakes: en-UK (the code is GB), jp (Japanese is ja), en_US (underscore), es-419 (numeric regions are not supported by Google).
  2. Self-reference. Every version lists all versions, including itself.
  3. Return links. If page A says B is its German version, B must say A is its English version. Google ignores pairs that are not confirmed in both directions, because anyone could otherwise claim your page as their alternate.
  4. Absolute, canonical URLs. Use full URLs with https://, and point to the canonical version of each page, which must return 200 and be indexable. An hreflang pointing at a redirect, a 404 or a page whose canonical points elsewhere is wasted.

x-default

x-default names the page for everyone else: visitors whose language or region you do not target. It is often the English version or a language-selector page. It is optional but recommended.

Worked example

A site with English (default), UK English and German versions. Every one of the three pages carries exactly the same block:

<link rel="alternate" hreflang="en" href="https://www.example.com/">
<link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/">
<link rel="alternate" hreflang="de" href="https://www.example.com/de/">
<link rel="alternate" hreflang="x-default" href="https://www.example.com/">

A searcher in Ireland using English gets en; one in London gets en-GB; one in Austria using German gets de; one in Japan using Japanese gets x-default. Note the plain en: if you only had en-GB and en-US, English speakers in Ireland, India or Australia would have no matching version.

Three ways to publish hreflang

  • HTML <link> tags in the <head>: simplest for small sites.
  • XML sitemap with <xhtml:link> children under each <url>: keeps pages light on large sites and is easier to generate from a database.
  • HTTP Link header: the only option for PDFs and other non-HTML files.

Use one method per page. Mixing them is allowed but makes conflicts easy to create and hard to find.

Sources

Last reviewed 2026-11-15. Your input is processed only in your browser and never sent to us.