01/22/2025 | Press release | Distributed by Public on 01/22/2025 04:35
Learn about the role hreflang attributes play in helping multilingual and multiregional websites show the correct language versions to users.
What Is Hreflang?
Hreflang is an HTML attribute that communicates a webpage's language-and possibly its target country-to search engines when the page has language or country variants.
For example, the hreflang attribute hreflang="en-us" signals that the specified page is written in English and targeted to U.S. audiences.
If you have multiple versions of your pages to serve different languages or countries, you should use hreflang in your search engine optimization (SEO) strategy.
Why Are Hreflang Attributes Important for SEO?
Hreflang attributes are important for SEO because they help ensure search engines display the correct versions of your pages based on users' languages and locations.
Like this:
When Google displays the most relevant page version, users are more likely to click your result, have a good experience on your website, and contribute to your business goals.
Hreflang attributes also help search engines find and understand relationships between localized pages.
Without hreflang, search engines may view translated or regionalized pages as duplicate pages. And this can harm your search visibility.
How to Implement Hreflang
To implement hreflang, identify a set of pages on your site that share the same content but for different languages or countries. Then assign each page a different identifier, depending on its targeting.
The anatomy of hreflang code is hreflang="value", where value is filled in based on one of the following:
Finally, follow one or more of the hreflang implementation methods below.
You can use hreflang tags in pages' HTML header elements (<head> sections) to inform search engines about the language/region targeting of a page and its variants.
An hreflang tag specifies a URL and its hreflang attribute, like this:
Every affected page should have an hreflang tag that references the source page and its variants.
For example, the tag highlighted below shows that the source page is written in German for audiences in Germany (de-de).
The other hreflang tags show that the page is also available in English for audiences in Ireland (en-ie), French for audiences in Guinea (fr-gn), etc.
These same hreflang tags are used on all other versions of the page as well.
For example, here's a snippet of HTML from the English version for audiences in Ireland:
Hreflang in the XML Sitemap
You can use hreflang in your website's XML sitemap to inform search engines about language and region targeting across your website.
The XML sitemap is a file that should list all the URLs you want search engines to index (add to the database of possible search results).
Here's what you need to do for pages with language/region variants:
For example, if you have two versions of a page, the corresponding XML code should look something like this:
Note that both URLs reference themselves and each other.
If you have a non-HTML page (like a PDF), you need to implement hreflang via the HTTP header.
Use this template to tell search engines about the language (and region if you wish) associated with the source page and its variants:
For example, you might add this to the HTTP header of all three listed pages:
Again, note that the variant pages should reference themselves and each other.
Best Practices for Hreflang
Follow these best practices when using hreflang on your website:
Use Canonical URLs in Hreflang Code
You should only use canonical URLs in hreflang code to avoid confusing search engines and harming your SEO performance.
A canonical URL is the main address for a webpage and the URL that search engines use in search results. Search engines ignore any alternate URLs to save resources and prevent duplication.
Let's say you can access the same page via three addresses:
You should only reference the canonical URL in hreflang code and avoid any alternate URLs.
In practice, this means you should not reference:
Keep Your Hreflang Code Updated
Update your hreflang code if you add, remove, or change URLs that have localized variants to avoid outdated code that can confuse search engines and harm your SEO.
Let's say you implement hreflang via your XML sitemap for your English and Spanish website.
If you later translate your site into German, you need to:
Audit Your Website for Hreflang Issues
Regularly audit your website for hreflang issues to check for any mistakes that could confuse or mislead search engines-and so harm your SEO.
Semrush's Site Audit tool can help you find and fix the most common hreflang SEO issues, including:
The Site Audit tool also helps you find and fix many other kinds of SEO issues. And free users can crawl up to 100 pages per month.