How to Implement Hreflang Tags Correctly on a Multilingual Site

What hreflang does, how language and region codes work, the three ways to add it, why return links and x-default matter, and the errors that break it.

Updated September 29, 2026 5 min read

Use the free Hreflang Tag GeneratorBuild hreflang link tags, sitemap entries or headers and validate codes

If your site has versions for different languages or countries, you want a searcher in France to land on the French page and a searcher in the United States to see prices in dollars rather than pounds. Hreflang annotations tell search engines which versions exist and who each one is for.

Hreflang is also one of the easiest things in technical SEO to get subtly wrong. A single invalid code or a missing return link can make search engines ignore the whole set. This guide explains how hreflang works, how to write the codes, the three places you can put it, and how to check it.

What hreflang does

Hreflang is an attribute on rel="alternate" links that says "this other URL is an equivalent page for people who speak this language, optionally in this region":

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

Google uses hreflang to choose which version to show in results. It is a signal, not a redirect: it does not move visitors and it does not by itself make a page rank. It helps the right version appear where the set already ranks.

Hreflang is mainly a Google convention. Other search engines may rely more on other signals, such as the lang attribute and content-language information, so it does no harm to set those too.

Language and region codes

A hreflang value has a language, and optionally a region:

  • Language: a two-letter ISO 639-1 code, such as en, fr, de, es, zh.
  • Region: a two-letter ISO 3166-1 alpha-2 country code, such as GB, US, MX, IN.
  • Separator: a hyphen. en-GB is correct; en_GB is not (underscores belong to Open Graph locales).

Common mistakes:

Wrong Why Right
en-UK UK is not the ISO country code for Britain en-GB
en_US Underscore instead of hyphen en-US
GB Region without a language en-GB
jp JP is a country; Japanese is ja ja or ja-JP
es-419 Numeric regions like Latin America are not supported by Google list countries: es-MX, es-AR

A script subtag is allowed for languages written in more than one script, such as zh-Hant for Traditional Chinese.

The rules that make hreflang work

Every page lists every version, including itself

If the UK page links to the US page, the US page must link back to the UK page. Google documents these as return links; without them, annotations may be ignored. The simplest approach is to put the same complete block on every version.

Use absolute URLs

Each href must be a full URL with protocol and domain.

Point to canonical, indexable pages

Hreflang URLs should return status 200, be the canonical version, and not be blocked or set to noindex.

Add x-default

x-default names the page for everyone not covered by the listed languages, often a language selector or the international English version. It is optional but recommended.

Provide a generic fallback where useful

If you have en-GB and en-US, English speakers in Australia match neither. Adding a plain en (which can point to one of the existing pages) catches them.

Three ways to add hreflang

  1. HTML link tags in the <head> of each page. Easiest for small sites.
  2. XML sitemap entries using xhtml:link. Better for large sites, because it keeps page HTML lighter and the whole map is in one place.
  3. HTTP Link headers, for non-HTML files such as PDFs that have no head.

Use one method per page set; mixing methods makes errors harder to track.

Generate and validate hreflang with our tool

The Hreflang Tag Generator produces all three formats and also checks existing code.

  1. Open the Hreflang Tag Generator on the Generate tab.
  2. Under Language versions, enter a code and URL for each version, such as en-GB and https://www.example.com/uk/. Use Add language for more rows, including one for x-default.
  3. Choose the output tab: HTML tags, XML sitemap or HTTP header. Copy the code, or download the HTML or sitemap version.
  4. Read the Checks. The tool flags underscores, invalid language codes, invalid regions such as UK, unsupported numeric regions, relative URLs, duplicate codes, a missing x-default and missing generic fallbacks, and reminds you that every page needs the same block.
  5. To audit an existing site, switch to Validate existing code, paste <link> tags, sitemap <xhtml:link> entries or a Link: header line into Existing hreflang code, and review the entries found and the checks.

Other ways to manage hreflang

CMS and multilingual plugins. Most multilingual plugins generate hreflang automatically when pages are linked as translations. This is the most reliable option because the set updates when you add a language. Check the output for codes like en-UK, which some configurations produce.

Crawlers. Site crawlers report missing return links and non-canonical targets across thousands of pages, which a single-page check cannot.

Search Console. Google removed its old International Targeting report, so rely on crawlers and validators for detailed hreflang auditing.

Troubleshooting

Google shows the wrong country version

Check return links, then check that the pages are genuinely different. Near-identical pages for GB and US may be treated as duplicates; localise prices, spelling and contact details.

Tags present but ignored

Look for invalid codes, relative URLs, targets that redirect, or canonical tags pointing to a different language.

Sitemap and HTML disagree

Choose one method and remove the other. If you use sitemaps, the XML Sitemap Generator builds the basic file and the hreflang generator shows the xhtml:link format.

Check a page's full head, including hreflang, with the Meta Tag Analyzer, and keep social locales consistent using og:locale from the Open Graph Generator.

Frequently asked questions

Is hreflang a ranking factor?

It does not boost rankings on its own. It helps search engines show the most appropriate language or regional version of a page that already ranks.

Do I need x-default?

It is recommended but optional. It tells search engines which page to show users whose language or region is not in your list.

Can two hreflang codes point to the same URL?

Yes. For example, en-GB and en-IE can both point to one English page for Europe. Each code, however, may point to only one URL.

Should the page reference itself?

Yes. Each page's hreflang set should include its own URL, along with all the other versions.

Is en-UK valid?

No. The ISO country code for the United Kingdom is GB, so use en-GB.

Try it now: Hreflang Tag Generator

Loading tool…