On-page

hreflang

Set up or fix hreflang annotations for sites with language or country versions. Use when a site has translated pages, when the wrong language ranks in a country, or when Search Console or an audit reports hreflang errors.

hreflang/SKILL.md

Facts to use

  • hreflang tells Google which URL is for which language or region. Three methods: HTML <link rel="alternate" hreflang="..."> tags, HTTP headers, or the sitemap. Google treats them as equal. Pick one method, because more than one adds work and no benefit.
  • Each language version must list itself and every other version. If page A links to page B, page B must link back to page A. Google ignores the tags when the two pages do not point to each other.
  • Codes: language in ISO 639-1 (for example en, de), optional region in ISO 3166-1 Alpha 2 (for example en-GB). A region alone is not valid.
  • x-default marks the fallback page for users who match no listed version.
  • URLs must be absolute and include https:// or http://.

Workflow

  1. List each page group: the same content in each language or region.
  2. For each group, write the full set of tags, one per version, plus x-default.
  3. Put the same set on every page in the group.
  4. Make each version's canonical point to itself, not to another language.
  5. Check that each URL returns 200 and is indexable.

Example

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

Checks

  • Every group has return links on every page.
  • Codes are valid.
  • No hreflang URL redirects or is noindex.

Output

A table per page group: URL, hreflang code, return links present (yes or no), fix.

Sources

  • Google: Tell Google about localized versions of your page. https://developers.google.com/search/docs/specialty/international/localized-versions
See all 30 skills