Hreflang for International SEO
Hreflang is an HTML attribute that tells search engines which language or regional version of a page to show to which users. If you have multiple versions of content (e.g., English for US, English for UK, Spanish for Spain), hreflang clarifies the relationships and prevents Google from ranking the wrong version for a user.
What Is Hreflang?
Hreflang (pronounced "H-ref-lang") is a link element in the HTML head that looks like:
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
This tells Google: "I also have a Spanish version of this page at this URL."
Language Codes vs Language-Country Codes
Hreflang uses language codes and optional country codes:
- Language only: hreflang="en" means English (any country)
- Language + country: hreflang="en-us" means English for US, hreflang="en-gb" means English for UK
- x-default: hreflang="x-default" is the fallback for users who don't match any specific language/country. Use this for your default version.
Example for a site with multiple versions:
<link rel="alternate" hreflang="en-us" href="https://example.com/en-us/" />
<link rel="alternate" hreflang="en-gb" href="https://example.com/en-gb/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
When to Use Hreflang
Multiple Language Versions
If you have content in different languages (English, Spanish, French, etc.), use hreflang. Google should show Spanish users your Spanish version, not your English version. Hreflang makes this explicit.
Country-Specific Versions
Even within the same language, you might have country-specific versions. Example: en-us, en-gb, en-au. Use hreflang to clarify. A user in Australia should see the Australian version if available.
Different Pricing or Content
If your content or pricing differs by country, use hreflang. Example: a product costs $99 USD but £75 GBP. Use hreflang="en-us" for the US version and hreflang="en-gb" for the UK version. This is legitimate country-targeting, not an abuse of hreflang.
The Reciprocal Rule: Mutual References
Here's a critical rule often missed: every page in a hreflang group must reference all other pages in the group. If page A (en-us) links to pages B (en-gb), C (es), and D (x-default), then:
- Page A must have hreflang tags for A, B, C, and D.
- Page B must have hreflang tags for A, B, C, and D.
- Page C must have hreflang tags for A, B, C, and D.
- Page D must have hreflang tags for A, B, C, and D.
If page A has an hreflang to B, but page B doesn't have an hreflang to A, Google might not respect the relationship fully. Always ensure reciprocal references.
How to Implement Hreflang
In HTML Head
Add hreflang tags to every page's <head> section. For pages with multiple language versions, list all versions:
<!-- On example.com/en-us/ -->
<link rel="alternate" hreflang="en-us" href="https://example.com/en-us/" />
<link rel="alternate" hreflang="en-gb" href="https://example.com/en-gb/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
In XML Sitemap
For large sites, hreflang in the sitemap is cleaner. You can specify alternate versions in the sitemap XML:
<?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/</loc>
<xhtml:link rel="alternate" hreflang="en-gb" href="https://example.com/en-gb/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/" />
</url>
</urlset>
In HTTP Headers
Advanced option: you can specify hreflang in HTTP headers instead of HTML. Rare, but useful for large-scale international sites. Requires server configuration.
Common Hreflang Mistakes
Missing Reciprocal Links
Page A links to B, but B doesn't link back to A. Google might ignore the relationship. Always ensure mutual references.
Wrong Language Codes
Using incorrect codes: "english" instead of "en", or making up codes like "en-united-states" instead of "en-us". Use standard ISO 639-1 language codes.
Hreflang on Pages That Are Actually the Same Language, Different Prices
This is legitimate if you have genuinely different content or pricing. But if two pages are identical except for a price, and you're using hreflang to rank different versions for the same country, that's an abuse. Use geo-targeting in Google Search Console instead.
Hreflang Pointing to 404 or Noindexed Pages
Ensure the target pages of hreflang tags are actually indexable and exist. Hreflang pointing to non-existent or noindexed pages breaks the relationship.
Testing Hreflang
Google Search Console shows hreflang issues under Coverage. If hreflang is broken or incorrect, GSC flags it. Use the URL Inspection tool to verify hreflang on specific pages.
Also validate hreflang manually: check a few pages and trace the hreflang chains. Ensure every page in a group references all others.
Hreflang Alternatives: Geo-Targeting
If you don't have separate URLs for different countries (just one URL with locale-switching), use Google Search Console's geo-targeting feature instead. In GSC Settings, set your target country. This tells Google which country you primarily serve.
Hreflang is for separate URLs; geo-targeting is for single URLs with country preference.