Hreflang is an HTML attribute used to specify the language and geographical targeting of a webpage. It helps search engines understand which version of your content to show to users based on their language or region.
For example, if you have a version of your website for English speakers in the U.S. (en-us) and a different version for English speakers in the U.K. (en-gb), hreflang tags allow you to indicate that clearly to Google and other search engines.
Without hreflang, you risk showing the wrong version of your page to users—or Google might choose the incorrect page to display in the search results, leading to poor user experience and lost visibility.
Hreflang is essential for international and multilingual SEO. It helps you:
Search engines try to match users with the most relevant content. Hreflang provides a direct signal to help them do that.
Hreflang acts as a bidirectional confirmation between two or more similar pages tailored for different languages or locations.
Here’s a simplified example:
This tells search engines:
– “https://example.com/us/” is for English-speaking users in the United States
– “https://example.com/uk/” is for English-speaking users in the United Kingdom
– “https://example.com/” is a default fallback when no specific language or region match is found
Each page must reference the other versions, forming a full hreflang cluster. If you don’t link all versions to each other, Google may ignore the tags entirely.
A common mistake is assuming hreflang and canonical tags serve the same purpose. They don’t.
– Canonical tags consolidate ranking signals from duplicate or similar content into one URL you want to rank.
– Hreflang tags indicate relationships between pages that are linguistically or regionally targeted but not duplicates.
Do not canonicalize your Spanish page to your English version. Doing so tells search engines to ignore the Spanish page. For hreflang to work as intended, each page should be self-canonical.
There are three main ways to implement hreflang:
Add <link rel="alternate">
tags to the <head>
of each localized page.
<link rel="alternate" hreflang="fr" href="https://example.com/fr/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
Use this method if you can edit your CMS or templates directly.
If you’re serving PDFs or other non-HTML files, you can declare hreflang tags in the HTTP header like this:
Link: <https://example.com/fr/file.pdf>; rel="alternate"; hreflang="fr",
<https://example.com/en/file.pdf>; rel="alternate"; hreflang="en"
If you can’t edit page templates, XML sitemaps are your best option. Here’s what the entry would look like in your sitemap:
https://example.com/en/
This method is scalable and easier to maintain for large websites.
The format of the hreflang attribute is based on ISO 639-1 for language codes and ISO 3166-1 Alpha 2 for country codes:
hreflang=”language-REGION”
Some common examples:
– en — English (generic)
– en-us — English (United States)
– en-gb — English (United Kingdom)
– es — Spanish (generic)
– es-mx — Spanish (Mexico)
– fr-fr — French (France)
– fr-ca — French (Canada)
Note: Google treats language-only codes the same as including a country. But including both gives you more precision.
The x-default value is used to specify the default fallback page when none of the other language or region variants are suitable.
Use this for:
– Language selection landing pages
– Geo-redirected homepages
– Generic fallback content
Example:
This helps users get to a relevant starting point when no exact hreflang match is found.
Implementing hreflang incorrectly can cause more harm than good. Avoid these mistakes:
Use these tools to validate your hreflang setup:
Audit regularly. Even one broken link in the hreflang setup can invalidate the entire cluster.
Hreflang is powerful, but it’s not always necessary. Don’t use it if:
– Your site is single-language and targets the same content to all regions
– You don’t have region-specific content (e.g., different prices, spelling, currencies)
– You just translate content without tailoring it to local markets
Instead, use other geotargeting signals like country-specific domains (ccTLDs) or Google Search Console’s location target setting.
Implementing hreflang correctly is one of the most effective strategies for global SEO. If your website targets users in multiple countries or languages, it’s a must-have to serve the right content to the right audience.
Do it right, and hreflang can improve visibility, reduce bounce rates, and drive more qualified international traffic. Do it wrong, and it can confuse search engines and users alike.