Hreflang Tags: How to Set Them Up and Fix Common Errors
Hreflang tags tell Google that several pages are versions of the same content for different languages or countries, so it can show each searcher the right one. They only work when every version lists all the others and itself, with valid codes, pointing to indexable pages.
When hreflang is missing or broken, the symptom is the wrong version ranking: the US page showing in the UK, or the English page in Quebec.
What hreflang tags look like
<!-- The same block goes on all three pages -->
<link rel="alternate" hreflang="en-us" href="https://example.com/pricing" />
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/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" /> Each line names one version. The block is identical on every page of the set, which is what makes the
links reciprocal. x-default is the fallback for anyone who matches none of the listed
versions.
Codes for the most common English and French markets
| Market | hreflang | Common mistake |
|---|---|---|
| United States | en-us | us alone |
| United Kingdom | en-gb | en-uk |
| Ireland | en-ie | Sharing the UK page without a tag |
| Canada, English | en-ca | Only the French version tagged |
| Canada, French | fr-ca | fr, which also targets France |
| Australia | en-au | Reusing the UK page for Australia |
| New Zealand | en-nz | Sending NZ to the Australian page |
| Any English speaker | en | Combining it with every country code needlessly |
How to set up hreflang
- List the sets of equivalent pages. Hreflang connects versions of the same page. The US pricing page, the UK pricing page and the French Canadian pricing page are one set.
- Choose the codes. Language alone (en, fr) when the page serves every country that speaks it; language plus region (en-gb, fr-ca) when prices, spelling or laws differ by country.
- Add x-default. The page for visitors who match no listed version, often the main English version or a country selector.
- Pick one method. HTML link tags for most sites, the XML sitemap for large sites, HTTP headers for PDFs and other files.
- Generate it from one source. Hreflang written by hand breaks as pages are added. The CMS, a plugin or the build should produce every block from the same list.
- Check with a crawler. Screaming Frog and the main audit tools report missing return links, invalid codes and non-200 alternates across the whole site.
For large sites, the same information can live in the XML sitemap instead of the pages:
<url>
<loc>https://example.com/pricing</loc>
<xhtml:link rel="alternate" hreflang="en-us" href="https://example.com/pricing" />
<xhtml:link rel="alternate" hreflang="en-gb" href="https://example.com/uk/pricing" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/pricing" />
</url>
<!-- repeat a <url> entry for /uk/pricing with the same links -->Common hreflang errors and how to fix them
| Error | What happens | Fix |
|---|---|---|
| No return link | Page A lists page B, but B does not list A, so Google ignores the pair | Put the same complete block on every page of the set |
| Wrong codes | en-UK, en-EU or es-LA are not valid and are ignored | Language in ISO 639-1, region in ISO 3166-1: en-GB, es-MX |
| Region without language | hreflang="gb" is ignored | Always start with the language: en-gb |
| Pointing to redirects or 404s | The alternate URL is not a real page | Use the final, indexable 200 URL of each version |
| Canonical to another language | Each version declares the US page as canonical, so only one is indexed | Every version is canonical to itself |
| Missing self-reference | The page lists the others but not itself | Include the page's own URL in its block |
| Mixed methods that disagree | HTML says one thing, the sitemap another | Pick one method and generate it from one source |
A canonical pointing across languages is the most damaging of these: Google keeps one version and drops the rest, reported in Search Console as "Duplicate, Google chose different canonical than user".
When you do not need hreflang
Hreflang is for equivalent pages. Pages written for different markets that are not translations of each other do not form a set. This site has separate pages for the UK, Canada and New Zealand, each written for its own market, so each one declares only its own language and region instead of pointing to the others.
The UK and Canada pages cover the market-specific cases in depth: sites for the UK and Ireland, and bilingual English and French sites selling into Quebec.
Questions about hreflang
What is hreflang used for?
Hreflang tells Google which version of a page to show to people in each language or country. It does not improve rankings by itself; it makes sure that someone in London gets the UK page with prices in pounds instead of the US page, when both exist.
Is it en-UK or en-GB in hreflang?
en-GB. Region codes follow ISO 3166-1, where the United Kingdom is GB. en-UK is not a valid code and Google ignores it. Codes are not case-sensitive, so en-gb works too.
Do I need hreflang for a site in one language?
No. Hreflang is only for pages that exist in several language or country versions. A site in English only, even with visitors in many countries, does not need it.
Does hreflang need to be on every page?
On every page that has alternate versions, yes, and each page must list all the versions, including itself. Pages with no equivalent in another language do not need it.
How do I check hreflang errors in Google Search Console?
Google retired the International Targeting report, which used to show hreflang errors, in 2022. Use a crawler like Screaming Frog or an audit tool to find missing return links and invalid codes, and URL Inspection to see which canonical Google chose for each version.
The wrong country version ranks?
Send the site and the countries or languages it serves. I reply with what Google sees in your hreflang and what to fix.
- Email: calebe.development@gmail.com
- WhatsApp: +55 11 98838-5247
- Who replies: Calebe Araujo, the developer who does the work
Page updated on .