Skip to content
Technical SEO

Hreflang and International SEO: A Practical Guide

13 min readPublished By Sanju Joseph

If your site exists in more than one language, or in one language for more than one country, search engines need help working out which version to show to which searcher. Without that help, a shopper in Sydney may land on your US page with prices in dollars and shipping rules that do not apply to them, and your UK and Irish pages may compete with each other for the same queries. Hreflang is the annotation that solves this. It tells Google, for each page, "here are the other language and regional versions of this page, and here is who each one is for."

Hreflang is also one of the most error-prone parts of technical SEO. It is easy to add, easy to get subtly wrong, and Google does not warn you loudly when it ignores your tags. This guide explains what hreflang does and does not do, the three ways to implement it with copy-ready code, how x-default and return links work, how to choose between country domains, subfolders and subdomains, and the mistakes that most often break international setups, including on Shopify Markets and WordPress with WPML or Polylang.

What Hreflang Does (and What It Does Not)

It helps to be precise about the job hreflang performs, because many international SEO problems come from expecting it to do more.

Hreflang is a swapping signal. When Google has already decided that one of your pages is relevant for a query, hreflang lets it swap in the most appropriate alternate for the searcher's language and location. Google's documentation on localized versions describes it in exactly those terms: it is a way to tell Google about the variations of your content so it can serve the right URL to the right user.

What hreflang does not do:

  • It does not make a page rank. A French page with no links, thin content or a noindex tag will not appear just because the English page points to it.
  • It does not consolidate signals like a canonical. Each language version stays its own indexable page. Hreflang groups them; it does not merge them.
  • It does not translate or geolocate anything. Visitors still need a page whose content, currency and language actually match.
  • It is not a command. Google treats hreflang as a hint. Conflicting signals, missing return links or wrong codes make it ignore the annotation.
  • It is not used the same way by every search engine. Google and Yandex support hreflang. Bing has said it relies more on other signals, such as the content-language meta tag, the lang attribute, and the location of the server and domain. If Bing traffic matters to you, set those as well.
Think of hreflang as a map that links equivalent pages together. Each page on the map still has to earn its place in search results on its own.

Language and Region Codes

Each hreflang value is a language code, optionally followed by a region code, separated by a hyphen:

  • Language: a two-letter ISO 639-1 code, such as en, fr, de, es, ja. This part is required.
  • Region (optional): a two-letter ISO 3166-1 alpha-2 country code, such as GB, US, AU, CA, MX.
  • Script (optional, rare): an ISO 15924 script code, used mainly for Chinese, such as zh-Hans (Simplified) and zh-Hant (Traditional).

Values are case-insensitive, but the convention is lowercase language and uppercase region, which makes them easier to read in audits. Some examples:

ValueMeaningValid?
enEnglish speakers, any countryYes
en-GBEnglish speakers in the United KingdomYes
en-UKNothing. "UK" is not an ISO 3166-1 codeNo. Use en-GB
es-419Spanish for Latin America (a UN M.49 region code)Accepted by Google, but test it; many tools flag it
de-ATGerman speakers in AustriaYes
USRegion only, no languageNo. A language is always required
euBasque (the language), not "Europe"Valid, but almost certainly not what you meant
x-defaultThe fallback for anyone not matched by another valueYes

You cannot target a region without a language, and you cannot target a group of countries (such as "Europe" or "LATAM") with standard codes, apart from the es-419 case above. If you have one page for all of Europe, either list it once per country with the right language codes, or treat it as a language-only page.

Also note what Google ignores: the lang attribute on your <html> element. Google's documentation says it does not use it (or other code-level language hints) to determine a page's language; it detects language from the visible content. You should still set lang correctly for accessibility, screen readers and Bing, but it will not fix hreflang.

Three Ways to Implement Hreflang

Google supports three methods. They are equivalent in effect. Pick one per set of pages and stick to it; mixing methods makes errors harder to find and can create contradictions.

Method 1: Link elements in the HTML head

The most common method. Every version of the page includes a full set of <link rel="alternate"> elements in its <head>, including one that points to itself.

<!-- On https://example.com/en-us/pricing/ AND on every alternate below -->
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/" />
<link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/preise/" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/tarifs/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />

Rules that matter: use absolute URLs including the protocol, place the tags in the <head> (Google stops reading head elements once it hits something that only belongs in the body, so an invalid element above them can hide them), and make sure the same block appears on every page in the group. If you would rather not write these by hand, the hreflang tags generator builds the full block from a list of URLs and locales.

Method 2: HTTP headers

For files without an HTML head, such as PDFs, send the annotations as a Link HTTP header:

Link: <https://example.com/en/guide.pdf>; rel="alternate"; hreflang="en",
      <https://example.com/de/leitfaden.pdf>; rel="alternate"; hreflang="de",
      <https://example.com/guide.pdf>; rel="alternate"; hreflang="x-default"

In Nginx this might look like:

location = /en/guide.pdf {
    add_header Link '<https://example.com/en/guide.pdf>; rel="alternate"; hreflang="en", <https://example.com/de/leitfaden.pdf>; rel="alternate"; hreflang="de"';
}

Header-based hreflang is the hardest to audit, because you cannot see it in the page source. Check it with the HTTP header checker.

Method 3: XML sitemap

For large sites, putting hreflang in the sitemap keeps page templates light and puts every relationship in one file. Each <url> entry lists all of its alternates, including itself, using the xhtml:link element:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://example.com/en-us/pricing/</loc>
    <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing/"/>
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/"/>
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/pricing/"/>
  </url>
  <url>
    <loc>https://example.com/en-gb/pricing/</loc>
    <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing/"/>
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/"/>
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/pricing/"/>
  </url>
</urlset>

Yes, this is repetitive: with ten languages, each URL carries ten xhtml:link lines and the file grows quickly. The normal sitemap limits of 50,000 URLs and 50MB uncompressed still apply, so international sites often split sitemaps by section and tie them together with a sitemap index. Our XML sitemap guide covers indexes and limits, and the sitemap validator checks that the file is well-formed before you submit it.

Which method should you choose?

MethodBest forWatch out for
HTML link elementsMost sites, CMS plugins, small to medium page setsPage weight with many locales; tags placed in the body; templates that drift apart
HTTP headersPDFs and other non-HTML filesInvisible in source; easy to forget on CDN or server changes
XML sitemapLarge sites, many locales, headless setupsGoogle only sees changes when it re-reads the sitemap; sitemaps out of sync with live URLs

Return Links: The Rule That Breaks Most Setups

Hreflang has to be bidirectional. If page A says "my German version is page B", then page B must say "my English version is page A". Google's documentation is explicit that if two pages do not both point to each other, the annotations may be ignored. This is deliberate: it stops a third party from declaring itself the German version of your page.

In practice, every page in a group should carry the identical set of hreflang annotations, including a self-reference. When you add a new locale, you have to update every existing page in that group, not just publish the new one. That is why hreflang tends to rot: someone launches a Spanish section, forgets to update the English templates, and the return links fail silently.

The most reliable fix is to generate the annotations from one source of truth (a database table, a CMS field or a translation plugin) rather than maintaining them per page. Then use the hreflang validator to fetch a page and each of its alternates and confirm that every relationship points back.

x-default: The Fallback Page

x-default tells Google which URL to show when no other hreflang value matches the searcher. For example, if you have en-GB, en-US and de-DE pages, a searcher in Brazil browsing in Portuguese matches none of them, so Google can show the x-default URL.

Common choices for x-default:

  • A language or country selector page that lets visitors choose.
  • Your main or international English version, if most unmatched visitors are likely to read English.
  • A page that redirects based on location or browser language, as long as Googlebot can still reach every version directly (see the section on redirects below).

x-default is optional, but Google recommends it, and it is cheap insurance. It also needs return links: the x-default page should carry the same hreflang block as the others.

How Hreflang Interacts With Canonical Tags

Hreflang and canonical tags work together, and contradictions between them are one of the most common reasons Google ignores hreflang.

  • Each language version should canonicalise to itself. The German page's canonical is the German page. Never point all locales' canonicals at the English page; that tells Google the translations are duplicates to be dropped, which defeats the purpose.
  • Hreflang must point at canonical URLs. If your hreflang tag lists https://example.com/de/preise but that URL's canonical is https://example.com/de/preise/ (with a trailing slash), or it redirects, the annotation points at a non-canonical URL and may be disregarded.
  • Same-language regional pages that are near duplicates (for example en-GB and en-AU pages that differ only in currency) are fine with hreflang. Google's documentation says hreflang helps it understand these are intentional regional variants. Localise what you can, such as prices, spelling, shipping and contact details, so they are genuinely useful to each audience.

The canonical checker shows what each page declares, and our canonical tags guide explains how Google chooses between signals when they disagree.

Choosing a URL Structure: ccTLD, Subfolder or Subdomain

Hreflang works with any URL structure, but the structure you pick affects maintenance, link equity and how clearly you can signal a country. Google's guidance on managing multi-regional sites lays out the trade-offs; here they are in table form:

StructureExampleProsCons
Country-code top-level domain (ccTLD)example.de, example.frStrongest, clearest country signal; trusted locally; separate hosting possibleExpensive; each domain builds authority separately; some ccTLDs have registration rules
Subfolder (subdirectory)example.com/de/Easy to set up; shares one domain's authority; one property to manageWeaker country signal on its own; one server location
Subdomainde.example.comEasy to host separately; clear separationCan be treated more like separate sites for linking; more properties to manage
URL parametersexample.com?lang=deSimple for developersNot recommended by Google; hard to segment and easy to break

For most businesses, subfolders are the practical default: one domain, one set of backlinks, one Search Console property with sub-segments, and hreflang to handle swapping. ccTLDs make sense when a country is a major market with its own team, brand presence or legal requirements. Note that some ccTLDs, such as .co, .io and .me, are treated by Google as generic top-level domains, so they do not signal a country.

Do not rely on a geotargeting setting in Search Console. The legacy International Targeting report, which let you set a country for a property, was retired in 2022. Today, country signals come from ccTLDs, hreflang, local content (currency, addresses, phone numbers) and local links.

Automatic Redirects and Language Detection

Many international sites redirect visitors based on their IP address or browser language. This is risky for SEO. Googlebot mostly crawls from US IP addresses, and Google's documentation notes that it generally does not send an Accept-Language header. If your server forces every US-located visitor to the English page, Googlebot may never see your German or French pages at all.

Safer patterns:

  • Suggest, do not force. Show a banner such as "Looks like you're in Germany. Visit the German site?" and remember the choice in a cookie.
  • Keep every locale reachable by a plain URL without cookies, headers or redirects, and link the language switcher with normal <a href> links so crawlers can follow them. If your switcher is built in JavaScript, read our JavaScript SEO guide for how Google handles script-generated links.
  • If you redirect, only redirect the x-default. A root URL that redirects to a locale is acceptable when it is the x-default and all locale URLs serve their content directly.

Platform Notes

Shopify Markets

Shopify Markets lets one store sell to several countries with local currencies, languages and domains. When you set up markets with subfolders (such as /en-gb/) or separate domains, and add languages through Shopify's translation features or a translation app, Shopify adds hreflang tags automatically for the published languages and markets. Things to check:

  • Make sure every language you publish is actually translated. Publishing a language with untranslated content gives you pages tagged as French that are mostly English.
  • Look at the rendered source of a product page in each market and confirm the hreflang block lists all markets, with absolute URLs and correct codes.
  • Review Shopify's automatic redirection and geolocation settings so Googlebot can reach every market URL directly.
  • If a theme or app adds its own hreflang tags on top of Shopify's, you end up with duplicates and conflicts. Remove one set.

The ecommerce SEO guide covers the rest of the Shopify setup, including product variants and collections.

WordPress with WPML or Polylang

The two most widely used WordPress multilingual plugins, WPML and Polylang, both output hreflang tags for translated posts and pages, including a self-reference, and both can add an x-default. The common failure points:

  • Untranslated content. If a post has no translation, the plugins generally leave that language out of the hreflang group for that post, which is correct. Problems start when "translations" are machine-generated placeholders or copies of the original.
  • SEO plugin overlap. Yoast SEO and Rank Math work with WPML and Polylang, but check that canonical tags on translated pages point to the translated URL, not the original.
  • Language in URL settings. Choose subfolders (/de/) or separate domains in the plugin settings rather than a ?lang= parameter.
  • Caching. Aggressive page caching that ignores language can serve the wrong language version, and the wrong hreflang block with it.

Headless and custom builds

Frameworks such as Next.js let you set alternates in page metadata. In the App Router, the alternates.languages field of the metadata object generates the link elements. Whatever framework you use, generate hreflang on the server from your routing configuration, so new locales are added everywhere at once and the tags are present in the initial HTML.

The Most Common Hreflang Errors

These are the problems that show up again and again in international audits, roughly in order of how often they appear:

  1. Missing return links. Page A points to B, but B does not point back. Usually caused by updating one template and not another.
  2. Missing self-reference. Each page should include itself in its hreflang set.
  3. Invalid codes. en-UK, en_GB (underscore instead of hyphen), jp instead of ja for Japanese, se (Northern Sami) when Swedish (sv) was meant, region-only values.
  4. Hreflang pointing to non-canonical, redirected, blocked or noindexed URLs. Google expects every URL in the set to be an indexable, canonical, 200-status page. The indexability checker confirms each one, and the redirect chain checker catches alternates that redirect.
  5. Relative URLs. href="/de/preise/" instead of the full https:// address.
  6. Canonical tags pointing all locales to one language. Covered above; this one removes your translations from the index.
  7. Tags outside the head, or after an element that closes the head early (for example a <div> or an <img> injected by a script).
  8. Conflicting methods. Hreflang in the HTML says one thing and the sitemap says another.
  9. Language mismatch. A page tagged fr whose visible content is in English. Google detects language from content, so this mismatch weakens the signal.
  10. Protocol or host mismatches. Annotations listing http:// or non-www URLs when the site lives on https://www..

How to Audit Hreflang

A repeatable process for a site of any size:

  1. Map your locales. Write down every language-region combination you serve, the URL pattern for each, and which page is x-default. This is your intended state.
  2. Spot-check key templates. For the homepage, a category page, a product or service page and an article, fetch each locale version and compare the hreflang blocks. They should be identical. The hreflang validator does this for you and flags missing return links and invalid codes.
  3. Check every target URL. Each listed URL must return 200, be indexable and canonicalise to itself. Run them through the HTTP status code checker in bulk.
  4. Crawl at scale. For larger sites, use a crawler that reports hreflang, or run a full site audit, to find templates where the annotations differ.
  5. Read Search Console data per market. With the International Targeting report gone, segment the Performance report by country and by page (filtering on the locale subfolder) to see whether each market's searchers land on the right version. A large share of German impressions going to English URLs is a sign hreflang is not working. Our Google Search Console guide walks through those filters.
  6. Check the language switcher and internal links. Each locale should link mostly to pages in the same locale, plus a crawlable switcher. The internal link analyzer shows where links point.
  7. Repeat after every launch. New locale, new template, new CMS plugin, new market on Shopify: each one is a chance for return links to break.

If you are running through a broader technical review at the same time, the international section of the technical SEO checklist and the interactive SEO checklist keep hreflang on the list alongside canonicals and sitemaps.

International SEO Beyond Hreflang

Hreflang gets the right page in front of the right searcher. Whether that page then ranks and converts depends on everything else:

  • Real localisation, not just translation. Local currency, units, spelling (colour versus color), payment methods, shipping, legal pages and support hours. Machine translation is fine as a starting point when a person reviews it.
  • Local keyword research. People in different countries use different words for the same thing, even in the same language. Do research per market rather than translating your English keyword list. Our keyword research guide covers the process.
  • Localised metadata. Titles, meta descriptions and Open Graph tags should be translated too. Check them with the meta tag analyzer.
  • Local links and mentions. Links from sites in the target country are a meaningful relevance signal, especially for subfolder setups.
  • Local business details. If you have offices in each country, give each one a page with its own address and LocalBusiness schema. The local SEO guide covers this.

AI assistants are another reason to localise properly. When ChatGPT, Perplexity or Gemini answer a question in German, they look for German-language sources. If your German pages are thin or half-translated, an assistant is more likely to cite a local competitor. See the AI visibility tracking guide for how to check which brands those engines mention in each market.

Frequently Asked Questions

Do I need hreflang if my site is only in one language?

No. If you have one version of each page for everyone, there is nothing to swap, and hreflang adds nothing. You need it when you have two or more versions of the same content for different languages or regions, including several English versions for different countries.

Is hreflang a ranking factor?

Not in the sense of boosting rankings. It helps Google show the most appropriate version among pages you already have. Indirectly, it can improve results by sending visitors to pages in their own language and currency, which tend to perform better, and by reducing the chance that your regional pages compete with each other.

Should I use en or en-US for my main English pages?

If you only have one English version, use en so it serves English speakers everywhere. If you have several English versions, give each one its region (en-US, en-GB, en-AU), and consider also adding a generic en entry pointing at whichever version should serve English speakers in other countries.

Can a page have hreflang and a canonical pointing elsewhere?

It should not. If a page's canonical points to a different URL, Google treats it as a duplicate of that URL, and hreflang annotations on it or pointing to it are likely to be ignored. Every page in a hreflang group should be canonical to itself.

How long does it take Google to pick up hreflang changes?

Google has to recrawl each page in the group (or re-read your sitemap) and see the matching return links before the annotations take effect, so changes usually show up over days to weeks, depending on how often your pages are crawled. Large sites with limited crawl activity can take longer; the crawl budget guide explains what affects that pace.

Does the html lang attribute replace hreflang?

No. Google has said it does not use the lang attribute to determine a page's language or target audience. Set it correctly for accessibility and for other search engines such as Bing, but use hreflang to tell Google about alternate versions.

What happens if I get hreflang wrong?

Usually nothing dramatic: Google ignores the broken annotations and falls back to its own judgement about which version to show. The cost is that the wrong country or language version may appear in results. The exception is when canonical tags are wrong at the same time, which can drop translated pages from the index entirely.