- hreflang tells Google which language and country versions of a page exist, so every user sees the right one.
- Each version names itself and all the others. If the return link is missing, Google ignores the annotation.
- hreflang only points to URLs that are reachable, indexable and canonical.
What does hreflang do?
If a page exists in several languages or for several countries, hreflang lets Google show the right version in every search. Google sometimes finds language versions on its own, but recommends declaring them explicitly. Google detects the language of a page with its own methods. Neither hreflang nor the HTML attribute lang is used for that.
Google does not treat translated pages as duplicates. Versions in the same language for different countries are a different matter, for example for Germany and Austria with almost identical text. Google may treat those as duplicates. hreflang then makes sure the Austrian URL still appears in Austria.
Do I need hreflang?
As soon as a page exists in several languages or in versions for different countries, hreflang is worth it. Google names three cases. The main content is fully translated. Only the navigation and footer are translated, while the main content stays in one language. Or there are versions in the same language with small regional differences. In practice, these set-ups come up most often.
| Set-up | Example | hreflang values |
|---|---|---|
| One language, several countries | English for the US, for the UK and for all other countries | en-US, en-GB, en |
| Several languages, worldwide | English, French and Spanish, each for all countries | en, fr, es |
| One country, several languages | US with an English and a Spanish version | en-US, es-US |
| Several countries, some of them multilingual | Country domains for Germany and Switzerland, with German and French in Switzerland | de-DE, de-CH, fr-CH |
| Regions instead of countries | One English version each for Europe, North America and Asia-Pacific | One value per target country, several values on the same URL |
There are no separate codes for regions. A version for Europe therefore gets one value for each country it is meant to reach. If your website has only one language and targets one country, you do not need hreflang.
Your URL structure does not have to match the hreflang value. Versions may sit on different domains, and Google does not use language subdomains such as fr.example.com to work out who a page is for. Which version is meant for whom is stated in the hreflang.
Language and country codes
The value consists of a language code according to ISO 639-1 and, optionally, a region code according to ISO 3166-1 Alpha-2, joined by a hyphen. Upper and lower case do not matter. Writing the region in capitals is common.
| Value | Meaning | Valid |
|---|---|---|
| de | German, for all countries | Yes |
| de-AT | German for Austria | Yes |
| en-GB | English for the United Kingdom | Yes |
| zh-Hant | Chinese in traditional script (script code according to ISO 15924) | Yes |
| x-default | Fallback for all other users | Yes |
| en-UK | UK is not the ISO code for the United Kingdom | No effect |
| be | Meant for Belgium, but stands for Belarusian. The first part is always the language. | Misread |
| es-419 | Google does not support Latin America as a region | No |
Use the plain language code as long as the content does not differ by country. Country codes are worth it when prices, shipping, legal details or wording differ. A URL can also carry several values, for example one version for Germany and Austria at the same time. The article Multiple hreflang values on one URL explains how.
x-default
x-default names the page for users whose language matches none of your versions. Google recommends it above all for language selector pages and homepages that redirect based on language or location. If you have no such page, you can name an existing version as the fallback, usually the English one.
Plan before you implement
A table of all versions saves a lot of mistakes later. For each version, note the address, language and target countries.
| Version | Language | Target countries | hreflang |
|---|---|---|---|
| example.com/de-de/ | German | Germany | de-DE |
| example.com/de-at/ | German | Austria | de-AT |
| example.com/de-ch/ | German | Switzerland | de-CH |
| example.com/en/ | English | all others | en, x-default |
Each combination of language and country appears only once. Then you decide which URLs are linked. An hreflang set should only contain pages that exist in several versions, return status 200, are indexable and canonicalize to themselves. A separate Search Console property for each version is worth it. That way you see indexing and search queries for each market separately.
Which domain strategy fits?
hreflang works with any structure. The structure itself is a signal too, though. Google describes the usual options with these pros and cons.
- Country-code domain (ccTLD), such as example.de. It shows users and search engines clearly which country the website is meant for. In return it targets only one country, costs more and needs more infrastructure.
- Subdomain on a generic domain, such as de.example.com. It is quick to set up and allows servers in different locations. Users often cannot tell the target country from the name alone.
- Subdirectory on a generic domain, such as example.com/de/. It is quick to set up and needs little maintenance, because everything sits on one host. Running the versions separately is harder.
Google does not recommend URL parameters such as ?loc=de. For hreflang, the country-code domain matters most. A version on example.co.uk is aimed at the UK. An hreflang value for Ireland on the same URL contradicts that signal. The case study From ccTLDs to one gTLD shows what moving from several country domains to one domain can achieve.
Three ways to implement it
Google treats all three methods the same. Pick one. Using several at once brings no advantage and is harder to maintain.
| Method | Suitable for | Keep in mind |
|---|---|---|
| HTML in the <head> | Most websites, easy to check | With many versions the head gets long. Redirecting x-default pages cannot carry a return link. |
| HTTP header | PDFs and other files without HTML | Invisible in the source code, some tools do not read headers |
| XML sitemap | Large websites with many versions, also across several domains | Each entry names all versions, including itself. |
HTML in the head
All versions carry the same block, each with full URLs.
HTTP header
For files, the server sets a Link header that is the same for all versions.
XML sitemap
In the sitemap, every <url> entry names all versions, including itself. You need the xhtml namespace for that. You can find more about sitemaps in the XML sitemap guide.
hreflang and canonical
Every language version points to itself with its canonical. A page with a canonical pointing to another URL gets no hreflang, and hreflang only points to canonical URLs. A canonical from one country version to another tells Google that only the target should be indexed. That contradicts the hreflang. Google also recommends that a page's canonical is in the same language. Examples with variants and country versions are in the article hreflang and canonical and in the canonical tag guide.
Special cases
hreflang via JavaScript and Google Tag Manager
Our own test from 2017 suggests that Google evaluates hreflang in the rendered HTML. hreflang annotations that Google Tag Manager had removed from the DOM no longer had any effect afterwards. The test ran on one website. The guide hreflang with Google Tag Manager describes how to add hreflang via GTM when your CMS cannot. You can find the test under JavaScript SEO experiment on hreflang. It is safer to deliver hreflang directly in the source code.
Checking hreflang
- Look at a single URL in the source code and in the rendered HTML. Is the same block on all versions? The free Hreflang Checker fetches every linked language version of a page for this.
- Open every target URL. It must return status 200, be indexable and canonicalize to itself.
- Check the return links. Each version names all the others and itself.
- Check the codes against ISO 639-1 and ISO 3166-1.
- Compare the page language with the hreflang value. Google detects the language from the visible content. If a page with
hreflang="fr"shows German text, the annotation is wrong. Google also advises using one language per page, for both content and navigation. - Compare the country-code domain with the country code. A URL on example.at with the value de-DE sends two signals that contradict each other.
- Check the language switcher. The versions should link to each other with normal HTML links so that users can switch themselves. Google recommends this explicitly.
- Compare the translations. Linked pages show the same content in their language. If only the template is translated and the main content is not, Google says this can create a poor user experience.
- For the whole website, use a crawl that brings all hreflang sets together. With thousands of URLs, there is hardly any other way to find gaps.
- In Search Console, track for each property which version ranks in which country.
Common mistakes
- The return link is missing. Google then ignores the annotation between the two pages.
- The page does not name itself.
- hreflang points to redirects, 404 pages or pages with noindex.
- Target URLs with a canonical pointing to another page.
- Relative URLs or a missing protocol.
- Wrong codes such as en-UK, or a country code without a language.
- The same combination of language and country for two URLs.
- The annotations sit outside the head, for example because a script writes them into the body.
- Users are redirected to a version automatically based on browser language or IP address. Google advises against this.
Frequently asked questions
Do I need x-default?
Not necessarily. Google recommends x-default for language selector pages and redirecting homepages. If you have such a page, you should declare it.
hreflang or canonical?
Each has a different job. The canonical consolidates duplicates onto one URL, hreflang connects language versions. Every language version has a canonical to itself and hreflang to all versions.
Does every page have to reference itself?
Yes. According to Google, each version lists itself and all other versions.
Can I specify only a country code?
No. The first part is always the language. “be”, for example, would be Belarusian and not Belgium.
How long does it take for hreflang to work?
Google has to recrawl all linked pages. On large websites this can take weeks. Google does not give a fixed time.
Sources
Retrieved on October 15, 2026. If something is out of date or missing, let us know.
- Google, Tell Google about localized versions of your page: https://developers.google.com/search/docs/specialty/international/localized-versions · As of 21 Sep 2026
- Google, Managing multi-regional and multilingual sites: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites · Retrieved 2 Nov 2026
- Google, How to specify a canonical URL: https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls · As of 10 Jul 2026
- Google, What is canonicalization?: https://developers.google.com/search/docs/crawling-indexing/canonicalization · As of 20 Aug 2026
- ISO 639, language codes (Library of Congress): https://www.loc.gov/standards/iso639-2/php/code_list.php
- ISO 3166, country codes: https://www.iso.org/iso-3166-country-codes.html