How-to Guides Web & HTTP

How to Add hreflang Tags to a Multilingual Site

Tell search engines which language version of a page belongs to which audience: list every version, make the tags reciprocal, add x-default and keep canonicals consistent.

Last reviewed:

AdSense Placeholder
Slot: header_reference_page
On this page

Steps

  1. List every language version of the page

    Write the full URL of each version, including the one you are on. Use one URL per language or region, and make sure each returns a normal page, not a redirect or an error.

  2. Choose the correct language codes

    Use a two-letter ISO 639-1 language code, optionally followed by a region such as en-GB or a script such as zh-Hant. The United Kingdom is GB, not UK. Add x-default for the fallback page, usually a language picker or your main language.

  3. Generate the annotations

    Paste the list into the hreflang Tag Generator (one language code and URL per line) and choose the output format: HTML link tags, XML sitemap entries or an HTTP Link header. The tool checks the codes and normalises their case.

  4. Place the full set on every version

    Every page must list all versions, itself included, and the annotations must be reciprocal. Paste the same block into the <head> of every version, or the same sitemap entries.

  5. Check canonicals and basic meta tags

    Each version should have a self-referencing canonical tag, never one pointing at another language. Verify it with the Canonical Tag Checker and review titles and descriptions per language with the Meta Tag Generator.

  6. Monitor for errors

    After the pages are indexed, watch your search console's international-targeting report for missing return links or unknown language codes, and fix any version that moved or was removed.

What you need

The URLs of every language or regional version of a page, and the ability to edit the <head> of each page (or your XML sitemap).

The same page in the three output formats

For an English page with Spanish and Canadian French versions, the HTML form is:

<link rel="alternate" hreflang="en" href="https://example.com/pricing" />
<link rel="alternate" hreflang="es" href="https://example.com/es/pricing" />
<link rel="alternate" hreflang="fr-CA" href="https://example.com/fr-ca/pricing" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing" />

The sitemap form carries the same information in one url entry:

<url>
  <loc>https://example.com/pricing</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/pricing" />
  <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/pricing" />
  <xhtml:link rel="alternate" hreflang="fr-CA" href="https://example.com/fr-ca/pricing" />
  <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/pricing" />
</url>

(The sitemap needs the xmlns:xhtml="http://www.w3.org/1999/xhtml" namespace on the root element.) Files such as PDFs have no head, so send the same annotations in an HTTP Link header instead.

Rules that decide whether the tags work

Rule Why
Every version lists every version, itself included The annotations must be reciprocal or they are ignored
Use absolute URLs Relative URLs are easy to get wrong
Language first, optional region second (en-GB) A region alone, such as GB, is not valid
x-default names the fallback It serves visitors whose language you do not cover
Canonical points to the version's own URL A canonical pointing to another language cancels the annotation

Common pitfalls

  • One-way links. If the English page lists Spanish but the Spanish page does not list English, both are ignored.
  • Wrong codes. en-UK should be en-GB; jp should be ja.
  • Pointing at redirects. Every URL in the set should return a normal page.
  • Mixing methods inconsistently. If the head and the sitemap disagree, you are asking search engines to guess.

Going further

The role of titles, descriptions and canonical URLs is covered in How SEO Meta Tags Work.

Try these tools

See also

  • Guide How SEO Meta Tags Work
    Title, description, canonical, hreflang, robots.txt.
  • Glossary hreflang
    The hreflang attribute tells search engines which language and region each version of a page is for, so users see the right one.
  • Glossary Canonical URL
    A canonical URL is the preferred address of a page when several URLs show the same content, declared with <link rel="canonical">.
  • Glossary Sitemap
    An XML sitemap is a file listing a site's URLs, with optional last-modified dates, to help search engines find and crawl pages.

Frequently Asked Questions

It does not boost rankings by itself. It helps search engines show the right language or regional version to each searcher and reduces the chance that a translation is treated as a duplicate.

The usual causes are missing return links (page A points to B but B does not point back), a version that redirects or returns an error, an invalid code such as en-UK instead of en-GB, and a canonical tag that points to a different language version.

Use one method per page and keep it consistent. HTML link tags suit most sites, an XML sitemap suits large sites with many versions, and an HTTP Link header is the only option for files such as PDFs.

AdSense Placeholder
Slot: footer_leaderboard