
Short answer: A hreflang tag is a link annotation that tells Google which language or country version of a page to show each searcher, for example English for the UK or Arabic for Saudi Arabia. To implement it, list every version of the page, including the page itself, with rel="alternate" and a valid code such as en-gb, add an x-default fallback, and make sure every version links back to all the others.
This guide is for site owners and developers running, or about to launch, a site in more than one language or for more than one country. You will learn what hreflang does and does not do, how to write valid codes, which of the three implementation methods suits your site, how to handle WordPress, Shopify and large catalogues, and how to find and fix the errors that affect most implementations. I also cover the Pakistan-to-Gulf and UK setups I work on most often. If you are still deciding whether to go multilingual at all, start with my guide to multilingual SEO.
What is a hreflang tag?
Hreflang is an annotation (rel="alternate" hreflang="x") that groups equivalent pages written for different languages or regions and tells search engines which one to show to which audience. A typical case: an e-commerce store in Lahore with English pages for Pakistan, English pages for the UK with pounds and UK delivery, and Arabic pages for the UAE. All three pages describe the same product, so without hreflang Google may show the UK page to someone in Karachi, or treat the two English pages as near duplicates and pick just one.
Hreflang does three useful things:
- It helps Google show the right version in each country and language, so searchers land on the correct currency, phone number and delivery terms.
- It lets similar pages in the same language (UK and Pakistan English, for example) exist without Google treating one as a duplicate to drop.
- It gives a fallback, through
x-default, for everyone who does not match any version.
It does not do three things people often expect. It does not translate anything. It does not boost rankings by itself; it only helps Google swap in the right version where your site already ranks. And Google says it does not use hreflang or the HTML lang attribute to detect the language of a page; it works that out from the content (Google Search Central). If the “Arabic” page is mostly English, hreflang will not fix that.
Hreflang syntax and valid codes
Each annotation has a language code and, optionally, a region code:
- Language: ISO 639-1 two-letter code, such as
en,ar,ur,de. - Region (optional): ISO 3166-1 Alpha 2 country code after a hyphen, such as
en-gb,en-pk,ar-ae,ar-sa. - x-default: the page to show when no other version matches, often a language selector or your main international version.
Google is explicit that you cannot use a country code on its own, and that reserved codes such as EU, UN or UK have no effect. The correct code for the United Kingdom is GB.
| You want to target | Correct | Common mistake |
|---|---|---|
| English speakers in the UK | en-gb | en-uk (UK is not a valid country code) |
| Arabic speakers in the UAE | ar-ae | ae-ar (order reversed) or ae (country only) |
| Urdu speakers anywhere | ur | pk (a country, not a language) |
| English speakers in Pakistan | en-pk | en_PK (underscore instead of hyphen) |
| All Spanish speakers | es | es-419 (a UN region code, not an ISO 3166-1 country code, so Google does not support it) |
| Everyone else | x-default | Leaving it out, so unmatched users get Google’s guess |
One more rule people miss: a language-only tag (en) catches all English speakers not covered by a more specific tag. So a set with en-gb, en-us and en sends Australians to the generic en page. That is usually what you want.
Rather have an expert do this for you?
Hand it over and get back to running your business.
The three rules every implementation must follow
- Return links. If page A lists page B, page B must list page A. Google’s documentation says that if two pages do not both point to each other, the tags will be ignored.
- Self-reference. Each page lists itself as well as all the other versions. The set is identical on every page in the group.
- Canonical, indexable URLs only. Every URL in the set should return 200, be indexable and be its own canonical. Pointing hreflang at a URL that redirects, returns 404, is noindexed or canonicalises elsewhere sends conflicting signals.
These rules are where most sites go wrong. Ahrefs’ 2023 study of 374,756 domains found that over 67% had hreflang issues; 56.3% lacked x-default, 18% lacked a self-reference, 16.9% pointed to redirecting or dead URLs and 15.3% were missing reciprocal links (Ahrefs).
How to implement hreflang: three methods
Google treats all three as equivalent. Pick one per site and stick to it; mixing methods makes errors harder to find.
1. HTML link elements in the head
Best for small to medium sites. Every page in the group carries the full set in its <head>:
<link rel="alternate" hreflang="en-pk" href="https://example.com/pk/sofas/" />
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/sofas/" />
<link rel="alternate" hreflang="ar-ae" href="https://example.com/ae-ar/sofas/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/sofas/" />Use absolute URLs, including https://. If your site renders the head with JavaScript, check in URL Inspection that the tags appear in the rendered HTML.
2. HTTP headers
For PDFs and other non-HTML files, send a Link header from the server:
Link: <https://example.com/pk/catalogue.pdf>; rel="alternate"; hreflang="en-pk",
<https://example.com/uk/catalogue.pdf>; rel="alternate"; hreflang="en-gb"3. XML sitemap
Best for large sites, because it keeps page HTML light and you can generate it from a database. The sitemap must declare the xhtml namespace, and each <url> entry lists every alternate, including itself:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/pk/sofas/</loc>
<xhtml:link rel="alternate" hreflang="en-pk" href="https://example.com/pk/sofas/"/>
<xhtml:link rel="alternate" hreflang="en-gb" href="https://example.com/uk/sofas/"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/sofas/"/>
</url>
<!-- repeat a <url> block for /uk/sofas/ and /sofas/ with the same three links -->
</urlset>My free hreflang tag generator and checker builds the HTML or sitemap version from a list of URLs, so you do not have to type the codes by hand. If you are new to sitemaps, my guide to XML sitemaps covers the basics.
| Method | Best for | Watch out for |
|---|---|---|
| HTML head | Sites up to a few thousand pages, CMS plugins | Page weight with many languages; JavaScript-rendered heads |
| HTTP header | PDFs and files | Server configuration access; easy to forget |
| XML sitemap | Large catalogues, many languages | Sitemap getting out of sync with live URLs |
Choosing a URL structure
Hreflang works with any structure, but the structure affects how easy it is to maintain. Google’s multi-regional sites guidance compares country domains (example.ae), subdomains (ae.example.com) and subdirectories (example.com/ae/), and does not recommend URL parameters such as ?loc=ae. For most of the Pakistani businesses I work with that sell to the Gulf or UK, subdirectories on one domain are the practical choice: one site to maintain, and authority shared across versions. My comparison of ccTLD vs subfolder vs subdomain goes through the trade-offs, and my multi-country website SEO guide covers planning the whole site. Exporters can also read my notes on international SEO for exporters.
The same guidance says to avoid automatically redirecting users to a language version based on their location or browser language, partly because Googlebot usually crawls from the US and could be redirected away from your other versions. Show a banner suggesting the better version instead.
Platform notes: WordPress, Shopify and headless sites
- WordPress: multilingual plugins such as WPML and Polylang output hreflang automatically once translations are linked. Check that untranslated pages are not left out of a set on one side only, which breaks reciprocity.
- Shopify: in my experience, Shopify Markets with published translations adds hreflang to the storefront automatically; confirm it in the page source. If you also use a separate store per country, you need to manage cross-store hreflang yourself, usually via a sitemap or app.
- Headless and JavaScript frameworks: generate the tags on the server so they exist in the initial HTML, and test in URL Inspection.
Worked example: a Karachi exporter selling to the UK and UAE
Imagine a textile exporter in Karachi with a site at example.com. It has a Pakistani English site for local buyers (prices in rupees), a UK English section (pounds, UK delivery), and an Arabic section for buyers in the UAE (dirhams, Arabic copy written by a native speaker, not machine translated). The plan:
- URLs:
/pk/,/uk/and/ae-ar/, with the root/as a short language and region selector. - Codes:
en-pk,en-gb,ar-ae, andx-defaulton the selector. - Products that are not sold in the UAE simply have no Arabic version; their set lists only
en-pk,en-gbandx-default, identically on both pages. - Each version has its own canonical (itself), local currency, phone number and delivery terms, so the pages are genuinely different for users, not just relabelled.
- Method: XML sitemap generated nightly from the product database, because the catalogue has thousands of SKUs.
Before building the Arabic section, the exporter would research what UAE buyers actually type, which is rarely a direct translation of the English keyword; my guide to international keyword research explains how. The most common failure I see in setups like this is the UK pages canonicalising to the Pakistani pages “because they are duplicates”. That cancels hreflang: Google drops the UK URL and shows the rupee price in London.
Hreflang implementation checklist
Hreflang implementation checklist
- List your markets: which language and country combinations genuinely need their own version.
- Choose a URL structure: subdirectories, subdomains or country domains; no URL parameters.
- Map equivalent pages: a spreadsheet with one row per page and one column per version.
- Use valid codes: ISO 639-1 language first, optional ISO 3166-1 country second, hyphen not underscore, gb not uk.
- Add x-default: a selector or your main international version.
- Self-reference every page: each page lists itself plus all alternates.
- Make every link reciprocal: identical sets on every page in the group.
- Use absolute, canonical, 200 URLs: no redirects, 404s or noindexed pages in the set.
- Keep canonicals self-referencing: never canonicalise one language or country version to another.
- Pick one method: HTML, HTTP header or sitemap, not a mix.
- Localise more than the language: currency, contact details, delivery and legal terms.
- Avoid automatic geo-redirects: offer a banner or selector instead.
- Validate: run a crawler or hreflang checker and inspect a sample in URL Inspection.
- Re-check after every launch: new pages and deleted products are where sets break.
Ticks are saved in your browser, so you can come back to the list during a rollout.
How to audit and fix hreflang errors
Crawl the site with a crawler that reports hreflang (Screaming Frog, Sitebulb, Ahrefs or Semrush site audits all do), then work through issues in this order, because each one can cancel the others:
- Non-200 or non-canonical targets: fix or remove links to redirected, deleted, noindexed or canonicalised URLs. My guide to canonical tags explains how the two interact.
- Missing return links: make the sets identical on both sides.
- Invalid codes: replace
en-uk, underscores and country-only values. - Missing self-reference and x-default: add them.
- Wrong-language content: if an “Arabic” page is half English, the tags cannot help; finish the translation.
Then check results in Search Console’s Performance report filtered by country: if UK users still mostly land on Pakistani URLs, something in the set is still being ignored. Hreflang problems often appear alongside duplicate content issues between near-identical English versions, so check both together.
Frequently asked questions
Do I need hreflang if my site is in one language?
No. Hreflang is only for sites with equivalent pages in more than one language or for more than one country. A single-language site gains nothing from it.
Is hreflang a ranking factor?
Not in the sense of boosting rankings. It helps Google pick which version of your page to show in each market where you already rank. Better matching can improve clicks and conversions, but it will not lift a page that does not rank.
Should I use en-uk or en-gb?
Use en-gb. Google says reserved codes such as UK and EU have no effect in hreflang, so en-uk is ignored.
Do I need x-default?
It is not mandatory, but I add it on every implementation. It tells Google where to send users who do not match any of your versions, and its absence is the most common gap in real-world audits.
Can hreflang point to a different domain?
Yes. A set can include example.com, example.ae and example.co.uk, as long as every page returns the links and all domains are yours. Verifying each one in Search Console makes troubleshooting easier.
What about Bing?
Other search engines handle language targeting in their own ways, and hreflang support varies. If Bing or another engine matters in your market, also set the HTML lang attribute correctly on every version and keep country signals (currency, address, phone) clear on the page. My guide to optimising for multiple search engines covers the differences.
Sources
- Google Search Central, “Tell Google about localized versions of your page” (documentation, accessed 2026).
- Google Search Central, “Managing multi-regional and multilingual sites” (documentation, accessed 2026).
- Ahrefs, “Over 67% of Domains Using Hreflang Have Issues” (August 2023).
- CSA Research, “Survey of 8,709 Consumers in 29 Countries Finds that 76% Prefer Purchasing Products with Information in their Own Language” (July 2020).
If you are planning a multi-country launch or your current hreflang set is showing the wrong version in the wrong market, my international SEO services cover the full setup and audit, or you can get in touch with your list of markets.
Request received
Thank you! Saad will contact you within the next 24 hours.
Keep an eye on your phone and inbox.
