What Is Hreflang and When Do You Need It
If your website serves visitors in more than one language, or the same language in more than one country, you may have noticed a problem. A visitor in London searches for a product and lands on the version written for the United States, with American spelling and American prices. A visitor in Berlin searches in German and lands on the English page instead. The content is not wrong, but it is not the version that fits that visitor best. Hreflang is the tool that helps search engines understand which language and regional version of a page to show to which audience. It is a small piece of markup with a large effect on how a multilingual site is understood.
This guide explains what hreflang is, in plain language, and when you need it. It covers how hreflang works, how to write it correctly, how to implement it in the head of a page or in an XML sitemap, and how to avoid the mistakes that can make it stop working. It also walks through a worked example with English for the United States, English for the United Kingdom, and German, and it answers common questions. You do not need to be a developer to follow the ideas, but you will need care and consistency if you add hreflang to a real site.
What Hreflang Means
Hreflang is an attribute used in a link element that tells a search engine about the language and, optionally, the region that a page is intended for. A typical hreflang tag looks like a link to another version of the same page, with a hreflang value such as en-US, en-GB, or de. The en part is the language code, and the US, GB, or DE part is the region code. Language codes use the ISO 639-1 format, with two lower-case letters, and region codes use the ISO 3166-1 Alpha-2 format, with two upper-case letters. So en-US means English as used in the United States, en-GB means English as used in the United Kingdom, and de means German without a specific region.
It is important to understand what hreflang does and does not do. Hreflang is a hint, not a strict rule. Search engines may use it to choose which version to show in results, but they can also show another version if they think it fits better. Hreflang does not translate a page for you, it does not redirect visitors, and it does not guarantee that a particular version will rank. What it does is reduce confusion. Without hreflang, a search engine may see several very similar pages in different languages or regions and treat them as duplicates, or it may show the wrong version to the wrong audience. With hreflang, the relationship between the versions is clear: they are alternates of the same content, intended for different audiences.
Hreflang is also a two-way relationship. If page A says that page B is its German alternate, page B should say that page A is its English alternate, and both should also refer to themselves. This is called self-referencing hreflang. It sounds repetitive, but it is how search engines confirm that the set of pages belongs together. A one-way hreflang tag, where only one page points to the other, is a common error and may be ignored.
When Do You Need Hreflang?
You need hreflang when you have more than one version of the same or very similar content for different languages or regions, and you want search engines to show the right version to the right audience. The clearest case is translation. If you publish the same article in English and in German, hreflang tells search engines that the German page is for German-speaking visitors and the English page is for English-speaking visitors. Without it, the pages may compete with each other, or the wrong one may appear in results.
You may also need hreflang when you have the same language in different regions, even if the text is mostly the same. English for the United States and English for the United Kingdom may differ only in spelling, currency, shipping information, or contact details, but those differences matter to visitors. A visitor in the United Kingdom who sees prices in US dollars and shipping information for the United States may leave, even if the product is the same. Hreflang helps search engines show the UK version to UK visitors and the US version to US visitors.
You do not need hreflang for a site that has only one language and one regional version. If your site is only in English for a single audience, adding hreflang will not help, and adding it incorrectly could cause confusion. You also do not need hreflang to handle a page that is simply available in different languages but is not the same content. If the German page covers a different topic from the English page, they are not alternates, and hreflang should not link them. Hreflang is for alternate versions of the same content, not for any page that happens to be in another language.
How to Use Hreflang
There are two common ways to implement hreflang: in the head section of each page, and in an XML sitemap. You can use either method, but you should not use both for the same pages in a way that creates conflicting signals. Choose one method, keep it consistent, and check it after you publish.
To use hreflang in the head, add a link element for each version, including the page itself. Each link has three parts: rel equals alternate, hreflang equals the language-region code, and href equals the full, absolute URL of that version. Use absolute URLs, not relative ones, so there is no doubt about which page you mean. For example, on the US English version of a page, you would include a link to the US version with hreflang en-US, a link to the UK version with hreflang en-GB, and a link to the German version with hreflang de. On the UK version, you would include the same three links. On the German version, you would include the same three links again. Every page in the set lists every version, including itself.
To use hreflang in an XML sitemap, add hreflang information to each URL entry in the sitemap, listing the alternate versions in the same way. This can be easier to manage for a large site, because you keep all the hreflang information in one file instead of editing every page. It also keeps the head of each page cleaner. The trade-off is that the sitemap must stay accurate. If a page is removed, moved, or changed, the sitemap must be updated too, or search engines will follow hreflang links to pages that no longer exist.
Whichever method you choose, follow these rules. Use the correct language and region codes, with the language in lower case and the region in upper case. Include a self-referencing tag on every page. Make sure every hreflang link points to a real, working page that returns a normal status, not an error. Make sure the set is complete and reciprocal, so every page lists every other page. And keep the content of the alternate pages truly equivalent. If one version is a short summary and another is a full article, search engines may not treat them as alternates.
Worked Example: en-US vs en-GB vs de
Suppose you run a small website that sells a guide. You have three versions of the same product page: one for the United States, one for the United Kingdom, and one in German. The US page is at example.com/guide/, the UK page is at example.com/en-gb/guide/, and the German page is at example.com/de/leitfaden/. The content is the same guide, but the US page uses American spelling and US dollars, the UK page uses British spelling and pounds, and the German page is a translation of the same guide.
On each of the three pages, you would include the full set of hreflang links. On the US page, the set would be: a link to example.com/guide/ with hreflang en-US, a link to example.com/en-gb/guide/ with hreflang en-GB, and a link to example.com/de/leitfaden/ with hreflang de. On the UK page, you would include exactly the same three links. On the German page, you would include exactly the same three links again. Each page therefore points to itself and to the other two versions. That self-referencing, reciprocal pattern is what makes the set trustworthy.
You might also add an x-default tag. X-default points to a default version to show when no other version matches the visitor, such as a language selector page or a general version. It is optional, but it can be useful if you have a page that lets visitors choose their language or region. If you use x-default, point it to a real page that helps visitors choose, not to a page that redirects them automatically without giving them a choice.
After you publish, you would check each page. You would view the source of the US page and confirm that all three hreflang links are present and correct. You would do the same for the UK and German pages. You would click each hreflang URL to confirm it loads. You would check that the codes are written correctly, with en-US and en-GB, not en-us in the wrong case or en-UK, which is a common mistake. The correct region code for the United Kingdom in this context is GB, not UK. You would also check that the German page is not pointing to a US page that has since moved, and that no hreflang link points to a page that returns an error.
Common Mistakes and Limitations
Wrong hreflang hurts. If you use the wrong language code, the wrong region code, or point hreflang to the wrong URL, search engines may show the wrong version, ignore the tags, or treat the pages as unrelated. Common mistakes include using UK instead of GB, using a language code that does not exist, pointing hreflang to a redirected page, pointing it to a page that returns a 404 error, and forgetting the self-referencing tag. Another common mistake is adding hreflang to pages that are not true alternates, such as a homepage in English and a contact page in German. Those pages are not versions of the same content, so hreflang should not link them.
Hreflang also has limits. It is a hint, not a guarantee, so search engines may still show a different version if they think it is more relevant. It does not fix thin or low-quality content, it does not fix a site that has no real translation and only a machine-translated page that is hard to read, and it does not replace good site structure. If your translated pages are poor quality, hreflang will not make them rank well. It will only help search engines understand which audience each page is for. You still need accurate translations, clear navigation, and working links.
Finally, hreflang can be hard to maintain on a large site. Every time you add, remove, or move a page, you need to update the hreflang set for every language version. If you use a plugin or a content management system feature to manage hreflang, check that it generates the full set correctly, and check it again after major changes. A small error in one language version can affect the whole set, because the tags are supposed to be reciprocal.
Frequently Asked Questions
Do I need hreflang if my site is only in English?
Usually no. If you have only one English version for one audience, hreflang is not needed. It becomes useful when you have the same content in more than one language, or the same language for more than one region, such as en-US and en-GB.
Should I put hreflang in the head or in the sitemap?
Either method can work. Use the head if you have a small site and you want the tags close to the content. Use the sitemap if you have a large site and you want to manage hreflang in one place. Do not use both for the same pages in a way that gives conflicting information.
What is a self-referencing hreflang tag?
It is a hreflang tag on a page that points to that same page. Every page in a hreflang set should include a tag for itself, as well as tags for the other versions. This confirms that the page belongs to the set and helps search engines trust the relationship.
Can wrong hreflang hurt my site?
Yes. Wrong codes, broken links, missing self-references, or linking pages that are not true alternates can cause search engines to show the wrong version or to ignore the tags. Check the codes, the URLs, and the reciprocity of the set after you publish.
Conclusion
Hreflang tells search engines which language and regional version of a page to show to which audience. Use it when you have alternate versions of the same content for different languages or regions, such as en-US, en-GB, and de. Include a self-referencing tag on every page, use correct codes and absolute URLs, keep the set reciprocal, and use the head or the sitemap, not conflicting versions of both. Check the tags after publishing, and fix any broken links or wrong codes quickly. Done carefully, hreflang reduces confusion and helps the right visitors find the version that fits them best.
Try a Tool
Free, in your browser — no sign-up.
Related Articles
How to Format XML So It Is Easy to Read
Learn how to format XML so it is easy to read: consistent indentation, one element per line, matched tags, unchanged data, and…
Read article →How to Build a Query String Without Breaking Your Link
Build a query string without breaking your link. Learn ?key=value, the & separator, encoding, a worked example, and why secrets stay out…
Read article →How to Convert Base64 Back to an Image
Learn how to convert Base64 back to an image, read a data URI, decode a 1 by 1 PNG example, check the…
Read article →