Hreflang Tags: What They Are and How to Set Them Up on a Multilingual Site
Hreflang tags tell Google which language or regional version of a page to show a user: the German page to someone searching in German, the British page to someone searching from the UK. Hreflang does not boost rankings or merge pages, it only helps Google put the right version in the results. Below are the syntax, the three ways to implement it, the rules without which Google ignores the markup, and a step-by-step setup for a site with several language versions.
Contents
- What hreflang does
- Syntax: language and region
- Three ways to implement hreflang tags
- Rules without which Google ignores hreflang
- Hreflang vs automatic IP redirects
- How to check your hreflang setup
- Common hreflang errors
- Example: a site with Ukrainian, Russian and English versions
- Hreflang checklist
- Frequently asked questions
- How I help with multilingual sites
- Summary
What hreflang does
Hreflang is an annotation that links pages with the same content in different languages or for different countries. When Google sees such a group of pages, it can show the one that matches the user's language and region in search results.
Three things to understand from the start:
- It is a signal, not a directive. Google treats hreflang as a hint and may choose another version if the markup is contradictory or the pages differ a lot in content;
- It does not pass ranking signals. Each language version ranks on its own, with its own links and content. Hreflang only helps swap one URL for another in the results;
- It does not replace strategy. Choosing markets, domain structure and keywords is a separate task, covered in the article on international SEO. This guide is about the attribute itself.
Syntax: language and region
A hreflang value consists of a language code and, optionally, a region code separated by a hyphen. The language follows ISO 639-1 (two letters), the region follows ISO 3166-1 alpha-2 (two letters). Case does not matter.
| Value | Meaning | Valid? |
|---|---|---|
| en | English, any country | Yes |
| en-GB | English, users in the United Kingdom | Yes |
| en-US | English, users in the United States | Yes |
| uk-UA | Ukrainian, users in Ukraine | Yes |
| ru-UA | Russian, users in Ukraine | Yes |
| en-UK | The code for the United Kingdom is GB, not UK | No |
| ua | There is no such language code | No |
Two classic mistakes come from the same confusion. "uk" is the language code for Ukrainian, so en-UK is invalid and the UK is en-GB. "UA" is the country code for Ukraine, so hreflang="ua" is invalid and Ukrainian is uk.
x-default: the version for everyone else
The x-default value marks the page to show when no language version matches the user. Usually it is the main language version or a language selector page. For an international product, x-default typically points to the English version.
Three ways to implement hreflang tags
Google supports three methods, and they are equivalent. Pick one and do not mix them, so you do not create contradictions.
| Method | Example | When it fits |
|---|---|---|
| Link tags in the <head> | <link rel="alternate" hreflang="en" href="https://site.com/" /> <link rel="alternate" hreflang="de" href="https://site.com/de/" /> <link rel="alternate" hreflang="uk" href="https://site.com/uk/" /> <link rel="alternate" hreflang="x-default" href="https://site.com/" /> | Regular HTML pages, most CMS-based sites |
| HTTP Link header | Link: <https://site.com/price.pdf>; rel="alternate"; hreflang="en", <https://site.com/de/price.pdf>; rel="alternate"; hreflang="de" | PDFs and other files that have no <head> |
| XML sitemap | <url><loc>https://site.com/</loc> <xhtml:link rel="alternate" hreflang="en" href="https://site.com/" /> <xhtml:link rel="alternate" hreflang="de" href="https://site.com/de/" /></url> | Large sites where generating a sitemap is easier than editing templates |
In a sitemap, declare the namespace xmlns:xhtml="http://www.w3.org/1999/xhtml" in the urlset tag, and each URL in a url block must list all versions, including itself. How to build the sitemap itself is covered in the guide to robots.txt and sitemap.xml.
Rules without which Google ignores hreflang
Most problems are not in the syntax but in the logic of the links between pages.
- Self-reference. Each page lists not only the other versions but also itself;
- Return links. If the English page points to the German one, the German page must point back to the English one. Google may ignore a one-way link;
- Absolute URLs. Only the full address with protocol and domain: https://site.com/de/, not /de/;
- One URL per value. Two different pages with hreflang="en" in one group is a contradiction;
- Consistency with canonical. Each version's canonical points to itself, that is, to the page in the same language. A canonical from the German page to the English one effectively tells Google not to index the German page, and hreflang becomes pointless. More in the article on canonical tags and duplicate pages;
- Working pages only. No URLs with noindex, redirects, 404 errors or blocked in robots.txt. Every URL in the group returns a 200 status code;
- Matching content. Link only real translations or local equivalents.
Hreflang vs automatic IP redirects
A common idea is to detect the visitor's country by IP and immediately send them to the "right" version. For SEO this is harmful. Googlebot crawls mostly from IP addresses in the United States, so with a forced redirect it may never see your German or French version at all.
Google recommends not redirecting automatically and giving users a choice instead: a language switcher on every page or an unobtrusive banner suggesting another language. Hreflang solves the problem of showing the right version at the search results stage, without redirects.
I will check the hreflang tags on your site
Send me your site URL - I will review the language version markup, canonicals and server responses and tell you which errors keep Google from showing the right version.
Message me on TelegramHow to check your hreflang setup
Google Search Console currently has no dedicated hreflang report: Google retired the International Targeting report several years ago. So checks are done with other tools.
- View page source. Find rel="alternate" and check the self-reference and the URLs;
- Screaming Frog SEO Spider. The Hreflang tab shows missing return links, invalid codes, links to noindex pages and canonical mismatches;
- Ahrefs Site Audit, Semrush Site Audit. Dedicated hreflang checks, convenient for regular monitoring;
- Search Console. The URL Inspection tool shows which canonical Google selected, and the Performance report filtered by country shows which version gets impressions in each country. More in the guide to Google Search Console.
Common hreflang errors
| Error | Consequence | How to fix |
|---|---|---|
| en-UK instead of en-GB | The UK version is not recognized | Replace with en-GB |
| No return links | Google may ignore the connection | The same set of tags on all versions |
| Canonical to another language | The version drops out of the index | Self-referencing canonical |
| Link to a redirect or 404 | The connection breaks | Use final URLs that return 200 |
Example: a site with Ukrainian, Russian and English versions
A typical structure for a business serving Ukraine: Ukrainian on the main domain, Russian and English in subfolders. As far as is known, Ukraine's state language law requires websites of companies serving consumers in Ukraine to have a Ukrainian version that loads by default. Check the details with a lawyer, but for SEO the conclusion is simple: the Ukrainian version is the main one, and x-default logically points to it.
Choose the codes
Ukrainian is uk, Russian is ru-UA if the audience is in Ukraine or ru if the version serves all countries. English is en without a region unless you have separate US or UK versions.
Build a mapping table
For each page, three URLs: https://site.com/poslugy/, https://site.com/ru/uslugi/, https://site.com/en/services/. If there is no translation, the page is simply left out of the group.
Add the tags to the template
Each of the three pages gets the same block of four tags: uk, ru-UA, en and x-default pointing to the Ukrainian version. Tags should be generated automatically in the template, not added by hand.
Check canonicals and indexing
Each version has a self-referencing canonical, no noindex, and all URLs return 200. The language switcher leads to the matching page, not to the homepage.
Crawl the site
After implementation, crawl the site with Screaming Frog or Ahrefs, and again after every template update. Hreflang most often breaks during a redesign.
Hreflang checklist
- Codes are valid: en-GB, not en-UK; uk for Ukrainian, never ua
- Each page references itself and all its language versions
- Links are reciprocal: the same set of tags on all versions
- All URLs are absolute, with https and the domain
- x-default is set
- Each version's canonical points to the page in the same language
- No URLs with noindex, redirects or 404 errors in hreflang
- No forced redirects by IP or browser language
- The site is regularly crawled for hreflang errors
Frequently asked questions
Do I need hreflang tags if my site has only two languages?
Yes. Hreflang is needed as soon as a site has at least two language versions of the same pages. Without it, Google may show a Spanish-speaking user the English page or the other way round.
Does hreflang affect rankings?
Not directly. It does not pass ranking signals between versions, it only helps show the right language version in the results. Indirectly, this improves click-through rate and user behavior.
Which is better: hreflang in the head or in the sitemap?
For Google, the methods are equivalent. Tags in the head are easier to check in the page source, a sitemap is more convenient for large sites. The key is to pick one method and keep it free of contradictions.
How much does a hreflang setup cost?
A hreflang audit and developer specification are part of the technical work in my monthly SEO service, which starts from $450/month. The first step is a free express audit, where I will tell you whether your language versions have problems.
How I help with multilingual sites
For six years I led SEO for Ukraine International Airlines, a site that served 40+ markets with dozens of language versions. There I saw how one template error can mix up versions in the results of whole countries. For multilingual sites I provide:
- a language version audit: hreflang, canonicals, redirects, indexing;
- a developer specification with a mapping table, and a check after implementation;
- ongoing SEO for each language version: keywords, content and links.
Monthly SEO starts from $450/month, and the exact budget depends on the number of languages, site size and competition. I work remotely, with written communication in English via Telegram or email. For a full review of the technical basics, see the technical SEO audit guide.
Summary
Hreflang is simple in syntax but demanding in logic. Use valid codes, self-references, reciprocal links, absolute URLs and x-default, keep hreflang consistent with canonicals and do not force-redirect users. After every site update, check the markup with a crawler.
Get a free express audit
I will check your site's language versions, hreflang tags and canonicals and give you a prioritized list of fixes. If needed, I can take the site on for monthly SEO.
Send a request