Technical SEO

How to Set Up hreflang Tags for Multilingual Sites

Add reciprocal hreflang annotations with HTML, HTTP headers or a sitemap, use the right language and region codes, and include x-default for unmatched languages.

FindSEO5 min read

A roadside bilingual sign on the Welsh side of Boundary Lane in Saltney, with the place name and instructions shown in both Welsh and English.

Photo: Rept0n1x / Wikimedia Commons (CC BY-SA 3.0)

In this article
  1. When do you need hreflang?
  2. Which method should you use?
  3. Which rules does Google enforce?
  4. An hreflang setup checklist
  5. The bottom line

To set up hreflang tags, create one URL for each language or regional version of a page, then tell Google about every version with HTML link tags, HTTP headers, or a sitemap. Pick one method. Each version must list itself and all of the others, using absolute URLs. Use language codes from ISO 639-1 and, when you need a region, ISO 3166-1 Alpha-2 (en-AU, not en-UK). Add x-default for unmatched languages, and keep the annotations reciprocal.

hreflang does not translate pages, and it is not a canonical tag. Google's documentation on localized versions says the tags help Google point people to the most appropriate version of a page. Google still detects the language of a page with its own algorithms, not from hreflang or the HTML lang attribute.

This matters when you have genuine local versions, which is also why site structure — a ccTLD, a subdomain or a subfolder — should be decided first. Our guide to ccTLD, subdomain or subfolder covers that choice.

When do you need hreflang?

Google recommends indicating alternate pages when:

  • The main content stays in one language and only the template is translated.
  • You have small regional variations of the same language, such as English for Australia, the United States and the United Kingdom.
  • The content is fully translated into more than one language.

You do not need hreflang for a single-language site, and you should not use it to paper over duplicate content on two URLs that are really the same page. If two URLs are copies, use a canonical instead.

Localized versions are only treated as duplicates when the main content is untranslated. Translated main content is not a duplicate problem in the sense Google describes there.

Which method should you use?

Google lists three equivalent methods. You may use more than one, but Google says there is no benefit in Search, and three implementations are harder to keep in sync. Choose the one your CMS or server can maintain.

HTML tags in the head of each version:

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

Every version gets the same set of tags, including a tag that points at itself.

HTTP headers are useful for non-HTML files, such as PDFs. Return a Link header on each version with the same reciprocal set of URLs.

Sitemaps use xhtml:link entries on each URL, with the xmlns:xhtml namespace declared. Each <url> entry must list itself and all alternates. If you already submit a sitemap, this can be the least fragile method on a large site. You can also point at those sitemaps from robots.txt.

Three equivalent ways to implement hreflang: HTML link tags in the page head, Link HTTP headers on each version, or xhtml:link annotations in a sitemap. Google treats them as equal, so pick one method and keep every version reciprocal, with absolute URLs and an x-default for unmatched languages.
Pick one method. Every version must list itself and all of the others.

Which rules does Google enforce?

The localized-versions documentation lists rules that apply to every method:

  • Each language version must list itself as well as all other versions.
  • Alternate URLs must be fully qualified, including https://. Relative URLs and protocol-relative URLs are not enough.
  • Alternate URLs do not need to be on the same domain, which is why a .com.au page can point at a .co.uk page.
  • If two pages do not both point to each other, the tags will be ignored. That stops a third party from naming itself as an alternate of your page.
  • If you have several regional variants of one language, also provide a catch-all for that language (en as well as en-AU, en-GB and en-US).
  • Add x-default for unmatched languages, especially on a language or country selector or an auto-redirecting home page.
  • hreflang rules: every version must list itself and all alternates with absolute https URLs and valid language and region codes such as en-AU or en-GB, plus return links. Avoid reserved region codes such as UK, EU or UN, and do not advertise a URL that is not crawlable.
    Return links and valid codes are what make the annotations count. The United Kingdom is GB, not UK.

Language codes must be ISO 639-1. A region alone is not valid. Region codes must be officially assigned ISO 3166-1 Alpha-2 codes. Google says reserved codes such as EU, UN or UK have no effect, so the United Kingdom is GB, not UK.

Google also says that if it becomes hard to maintain a complete bidirectional set, you can omit some languages on some pages and it will still process the pairs that point to each other. New language versions should still link bidirectionally to the original or dominant language.

After you publish the annotations, use Search Console to watch International Targeting issues if they appear, and test a sample of live URLs. Our hreflang checker is a way to inspect a page's annotations. When you migrate a site, rebuild the hreflang set for the new URLs rather than leaving tags pointing at old addresses.

A bilingual Welsh and English road-name sign for a street in Brynmawr, with the Welsh name stacked above the English name on a white plate.
Use en-GB for the United Kingdom, not en-UK. Google ignores reserved region codes such as UK, EU and UN. Photo: Jaggery, CC BY-SA 2.0, via Wikimedia Commons.

Google's troubleshooting section on the same documentation highlights the most common mistakes: missing return links, incorrect language codes, and incorrect region codes. If page X points at page Y, page Y must point back at page X. A language code on its own is valid; a region code on its own is not. For a fuller note on x-default, Google's x-default explanation is the official commentary.

If you implement hreflang in a sitemap, follow the sitemaps protocol and Google's guidance on combining sitemap extensions. Keep the sitemap reserved for canonical, indexable URLs, as you would with any sitemap. If two URLs are not truly alternate versions, do not link them with hreflang; consolidate duplicates instead.

After a large change, recrawl can take time. Check a sample of HTML heads or sitemap entries by hand, then watch Search Console for coverage problems on the new or moved URLs. hreflang will not fix a page that is blocked, canonicalised away, or returning an error.

If your English-language Australian, British and US pages are close variations rather than full translations, they still need their own URLs and a complete annotation set. Google's documentation lists that regional case explicitly. What you should not do is show one URL to everyone and swap the text with JavaScript or IP detection only. Each version you advertise in hreflang should be a stable, crawlable URL. Auto-redirects that send an Australian user from the US URL to the AU URL can still be fine, but the AU URL must stand on its own, return the Australian content, and be the URL you list in the en-AU annotation. If a crawler cannot reach that URL without a user cookie or a blocked parameter, the annotation will not help.

An hreflang setup checklist

  • Each language or region has its own URL, with real content for that audience.
  • You have picked one method: HTML, HTTP headers or a sitemap.
  • Every version lists itself and all alternates, with absolute https:// URLs.
  • Return links are in place; no page points at a version that does not point back.
  • Language and region codes are valid (en-AU, en-GB). You have not used UK, EU or UN.
  • A language-level catch-all and an x-default URL exist where they are needed.
  • A sample of pages has been checked with a live test, and sitemap or HTML errors have been fixed.

The bottom line

hreflang is a map of equivalent pages, not a ranking trick. Give each audience a real URL, pick one implementation method, and keep the annotations reciprocal, complete and coded correctly. Get the site structure right first, then maintain the tags whenever you add a language or change a URL. For help with a multi-market site, compare international SEO services or get matched with an agency.

FAQs

Do I have to use HTML tags, HTTP headers and a sitemap together?

No. Google says the three methods are equivalent and that using all three at once has no benefit in Search. It is usually harder to maintain three implementations than to do one well. Pick the method your site can keep accurate.

Why must hreflang tags be reciprocal?

Google says if two pages do not both point to each other, the tags will be ignored. That prevents someone on another site from declaring themselves an alternate version of your page. Each version must also include a tag that points at itself.

Should I use en-UK for the United Kingdom?

No. Google says region codes must be officially assigned ISO 3166-1 Alpha-2 codes, and that reserved codes such as UK, EU and UN have no effect on Google Search. Use en-GB for British English.

Does hreflang tell Google the language of a page?

No. Google says it does not use hreflang or the HTML lang attribute to detect the language. It uses its own algorithms for that. hreflang only indicates that pages are localized variations of the same content.

What is hreflang x-default for?

x-default marks the URL to use when no other language or region matches, such as a language selector or an auto-redirecting home page. Google recommends adding it, especially in those cases.

Sources

Ready for help with SEO?

Compare SEO-only agencies near you, with client reviews checked by a person, or tell us what you need and get matched.