Implement page signals and migrations

How to Add HTML Hreflang Tags to Equivalent Pages and Check Their Canonicals

Add HTML hreflang links to English and Spanish pages, then check every published URL for return links, self-references and matching canonicals.

Editorial illustration for How to Implement and Verify Hreflang for Equivalent International Pages

For a small set of equivalent HTML pages, put the same complete set of hreflang links in every page’s head, including a link to that page itself. Then inspect every published URL. Finding three correct tags on the English page does not tell you what the Spanish page or the fallback page serves.

This example uses a US English product page, a Mexican Spanish version of that product page, and a language selector:

  • https://example.com/en-us/product/
  • https://example.com/es-mx/product/
  • https://example.com/language-selector/product/

These are hypothetical URLs and markup, not a deployed or tested implementation. The selector is the x-default fallback, not a third product translation. Google describes x-default as the value for a URL used when no listed language or region matches, and recommends it particularly for language-selector pages (Google Search documentation).

Put the complete set in each HTML head

Each rel="alternate" link pairs a fully qualified URL with its hreflang value. The two product alternatives use en-US and es-MX; the selector uses x-default. Google requires each language version to list itself and the other versions, and requires fully qualified alternate URLs. The repeated links below are intentional, not duplicate pages to remove from a template.

On https://example.com/en-us/product/:

<html lang="en-US">
<head>
  <link rel="canonical" href="https://example.com/en-us/product/">
  <link rel="alternate" hreflang="en-US" href="https://example.com/en-us/product/">
  <link rel="alternate" hreflang="es-MX" href="https://example.com/es-mx/product/">
  <link rel="alternate" hreflang="x-default" href="https://example.com/language-selector/product/">
</head>
<body>
  <p>Example product page in English.</p>
</body>
</html>

On https://example.com/es-mx/product/:

<html lang="es-MX">
<head>
  <link rel="canonical" href="https://example.com/es-mx/product/">
  <link rel="alternate" hreflang="en-US" href="https://example.com/en-us/product/">
  <link rel="alternate" hreflang="es-MX" href="https://example.com/es-mx/product/">
  <link rel="alternate" hreflang="x-default" href="https://example.com/language-selector/product/">
</head>
<body>
  <p>Página de ejemplo del producto en español.</p>
</body>
</html>

On https://example.com/language-selector/product/:

<html lang="en">
<head>
  <link rel="canonical" href="https://example.com/language-selector/product/">
  <link rel="alternate" hreflang="en-US" href="https://example.com/en-us/product/">
  <link rel="alternate" hreflang="es-MX" href="https://example.com/es-mx/product/">
  <link rel="alternate" hreflang="x-default" href="https://example.com/language-selector/product/">
</head>
<body>
  <p>Choose a language for this product page.</p>
</body>
</html>

The selector’s lang="en" describes its English-language interface in this example. It does not turn the selector into the en-US product alternative: that hreflang link names the English product URL. Similarly, x-default names the selector URL, including on the selector itself. The lang value on the opening HTML element and the hreflang values on alternate links have different jobs.

Notice the canonical on each page. The English canonical equals its en-US self-reference; the Spanish canonical equals its es-MX self-reference; and the selector canonical equals its x-default self-reference. This keeps the URLs named as alternatives aligned with the URLs each page declares as its own preferred version. Screaming Frog’s hreflang audit guidance says hreflang should include canonical versions of URLs. A cluster check that reads only the alternate links would miss a conflicting canonical.

Check all three URLs after publishing

Hreflang can also be delivered through HTTP headers or XML sitemaps, as covered in that audit guidance. This example uses HTML links. If a CMS or shared template produces the head, inspect the output at each of the three URLs rather than assuming every locale received the same result.

For each published URL, check its response and the HTML head it serves. Compare the three hreflang-value and URL pairs with the example set. Check the page’s own pair in particular: en-US must point to the English page on the English URL, es-MX to the Spanish page on the Spanish URL, and x-default to the selector on the selector URL. Then read that page’s canonical and compare it with the same self-referencing URL. Do not stop after finding a correct canonical on only one member of the cluster.

Check the return relationships too. The Spanish page must name the English URL, the English page must name the Spanish URL, and the selector must publish the same set. Google says annotations between two pages are ignored if the pages do not both point to each other (Google Search documentation). Finally, make sure each annotated URL returns its intended page directly, without a redirect or error. Screaming Frog treats non-200 hreflang targets as audit errors, including redirects and 4xx responses.

A hreflang checker or crawl can help locate missing return links and affected URLs, but confirm any reported failure against the page actually served. If a URL has the wrong canonical, lacks a link, redirects, or serves an error, correct that page’s output or the target URL and check the entire three-URL set again. Passing these checks establishes that the published annotations, canonicals and responses are internally consistent. It does not establish that Google has indexed the pages or will display a particular version.

Find a note

Search by topic, title, or keyword.