Hreflang is an annotation that tells Google that several URLs are language versions of the same content. Based on it, the search engine decides which URL to show to a user from a given language or country. Sound familiar?
A customer from Germany types in your company name and lands on the Polish page instead of the German one. This usually means the annotations are missing or something in them is wrong. Below I describe how hreflang works, three ways to add it, what x-default is for, how to check the implementation and which mistakes happen most often.
Table of contents
What is hreflang and what does it really do in Google?
Hreflang shows Google the localized equivalents of a page, so that the URL in the user’s language appears in the search results. That’s all. It is not used to detect language (a common myth). According to Google’s documentation on localized versions, the search engine uses neither hreflang nor the HTML lang attribute for that, only its own algorithms. The annotation simply directs the right version to the right audience. When do you need it? When languages or regions have separate URLs, e.g. /de/ and /en/, or separate domains.
How to add hreflang: tags in the head, HTTP headers or a sitemap?
Google accepts three methods: link tags in the head section, the HTTP Link header or an XML sitemap. Pick one, the one that fits your site. Mixing them gains you nothing. The tags must sit in a correctly built head section, so if you have doubts, paste the rendered page code into an HTML validator. Also, do not combine hreflang with other attributes, e.g. media, in a single link tag. And the HTTP header? It comes in handy for PDF files and other documents that are not HTML. Every version returns exactly the same set in it.
<link rel="alternate" hreflang="pl" href="https://example.com/pl/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/" />Rules for a correct set of page language versions in Google
Every version of a page lists all the variants with full URLs, including itself. It sounds trivial, yet this is exactly where most implementations fall apart. In practice I recommend this order:
- List all the variants of a given subpage.
- Assign two-letter language codes according to the ISO standard and, if needed, add a region, e.g. de-AT for Austria.
- Use full, canonical URLs with the protocol.
- Add a link from the page to itself.
- Make sure it is reciprocal: the same set must be on every version.
- Add x-default for all other users.
A separate story is similar content in the same language under different URLs, e.g. example.de/ and example.com/de/. Here Google’s guide to multi-regional sites recommends choosing a preferred version and combining rel=canonical with hreflang. The result? The user gets the URL that matches their language or region.
What is x-default hreflang for?
The x-default value points to a fallback page for users whose language you do not support. It is most useful for a language selection page or for a homepage that redirects visitors on its own. Implementation is simple: next to the others, you add one more link tag with hreflang=”x-default”. It should point to the URL where someone speaking a language outside your list should land. A real-world example: the web-systems.pl homepage has pl, en, de and x-default annotations, and WPML generates them.
Hreflang in WordPress: what the plugin does and what you need to check
Multilingual plugins such as WPML generate hreflang automatically. But only for pages with linked translations. If someone created the German version as a separate page, without connecting it to the Polish one, the plugin will not treat them as equivalents. And that subpage is left without annotations, and you do not even know about it. So after adding content, look into the code of a few of your most important URLs, it is five minutes of work. If you are only just choosing a tool, compare the available WordPress translation plugins. With a new site, it is best to plan the language structure already when you order website development for your business. Reworking it later is much harder.
The most common hreflang mistakes and how to catch them
Most problems come from missing reciprocity, wrong language codes and URLs that redirect or have a different canonical. The list of sins looks more or less like this:
- no return link from one of the versions,
- a country code instead of a language code, e.g. uk for the United Kingdom instead of en-GB,
- hreflang pointing to a URL that redirects or has noindex,
- a canonical pointing to a different language version,
- tags outside the head section, e.g. injected into the body,
- relative URLs instead of full ones.
For checking, viewing the source of the rendered page and an HTML validator are entirely enough. With a large number of subpages, third-party hreflang debugging tools help. Just note: Google points out that it does not maintain or check them. On a large site, in my opinion it is better to order a multilingual website SEO audit than to click through it by hand for weeks.
Where to start? With a list of the variants of the homepage and the most important subpages. Then check in the code whether each of them lists all the versions and x-default. A well-implemented hreflang does one simple thing: a customer from Germany sees the German page in Google, and a customer from Poland sees the Polish one. If you prefer to hand this over to specialists, consider professional search engine optimization.
Frequently asked questions
Does hreflang improve a site’s rankings in Google?
No, hreflang is not meant to improve rankings. It helps Google show the user the right language version of the same content. Thanks to this, the visitor lands straight on the page in their own language.
Do I have to use x-default?
X-default is not mandatory. But if you have a language selection page or a homepage with an automatic redirect, add it. Users whose language you do not support will then land on the fallback page.
Is the lang attribute in the html tag enough?
No, it is not enough. Google does not use the lang attribute either to indicate language versions or to recognize the language of a page. To connect the equivalents, you need hreflang in the head section, in the HTTP header or in the sitemap.








