If you have an international audience, your website - and digital marketing efforts - will benefit from using hreflang tags.
The hreflang attribute tells Google which language and country you are targeting for a specific page. This allows the search engine to serve the page result to users searching in that specific language and country.
Think of the hreflang tag this way…when a user searches in language x, the hreflang tag ensures the search result is also delivered in language x, rather than language y or z.
At its core, the hreflang tag is all about creating a great user experience.
It is important to note, an hreflang tag acts as a signal to search engines, not as a directive. Google’s knowledge base does say that even if you don’t use the hreflang attribute, the Google search engine:
“... might still find alternate language versions of your page, but it is usually best for you to explicitly indicate your language- or region-specific pages.”
Now, let’s be real, if Google’s saying it’s best to explicitly indicate your language- and region-specific web pages, you should do it. To help with the sometimes complex technical SEO effort of hreflang implementation, this post has been designed as a guide to answer questions about hreflang tags, including:
- Answering questions about what the hreflang tag is in detail
- Benefits of using hreflang tags
- When you should use hreflang
- How to implement hreflang tags
- Common hreflang mistakes
- How to avoid and prevent hreflang errors
Doing hreflang may not be easy – it requires process and patience, – but when done right the benefits for brands with international websites and their audiences are immense.
What is the hreflang tag?
The hreflang tag is a snippet of code that tells Google which language to use when serving search results to a geo-targeted audience. You may also see it referred to as:
The code enables an international website to serve results based on the search language or searcher’s location.
<link rel="alternate" href="http://example.com" hreflang="en-us" />
This code tells Google that this English version of the page is specifically directed to a U.S. audience.
When should I use the hreflang tag?
The hreflang tag makes sense for any brand doing global SEO when:
- Your website has the same content in different languages. For example, using the hreflang=”es-es” signifies Spanish for Spain rather than hreflang=”es-mx”, which signifies Spanish for Mexico.
- Your website has different content in the same language. For example, your website has English language content for Australia, Great Britain, and the U.S., but specific offers (ie., in local currencies) for each. In this case it would like:
The hreflang tag gives your content a global SEO boost. Like canonical tags, hreflang helps to avoid penalties associated with duplicate content across global sites. In addition to having content in multiple languages, you can also have content targeted towards variants of a single language. This allows you to localize your content for a specific language region. For example, using the hreflang=”es-es” signifies Spanish for Spain rather than hreflang=”es-mx”, which signifies Spanish for Mexico.
What is the benefit of using hreflang?
Hreflang gives your content a global SEO boost. In addition to having content in multiple languages, you can also have content targeted towards variants of a single language. This allows you to localize your content for a specific language and region.
Ultimately, you want to use hreflang for these two reasons:
- For a better user experience. Content created specifically for an audience and delivered in their own language will resonate, engage and meet the user search expectation. This leads to a lower bounce rate and better page rankings.
- To prevent duplicate content issues. If you have pages with the same content in different languages or regionally specific content in the same language, Google might not understand and see it as duplicate content, which can impact page ranking. Like canonical tags, hreflang helps to avoid penalties associated with duplicate content across global sites.
How is hreflang different from canonicalization?
Hreflang tells a search engine which page to show a user based on language or region. Canonicalization tells the search engine which version of a URL to index when those different versions of a URL contain the same content.
How do I implement the hreflang?
You can use language annotations in one of three different ways:
- HMTL link element in the header. Add a link element to the HTML <head> section to point towards a specific language:
<link rel="alternate" hreflang="es" href="http://es.example.com/" />
- HTTP header. If you publish PDFs or other non-HTML files, use the HTTP header to indicated a different language version:
Link: <http://es.example.com/>; rel="alternate"; hreflang="es",<http://de.example.com/>; rel="alternate"; hreflang="de"
- XML Sitemap. Instead of using HTML markup, you can also submit language version information in your sitemap. Google shares this example for telling the search engine that your English website has equivalent pages for worldwide German speakers as well as a page specifically for Swiss-based German speakers.
Regardless of which method you use, an hreflang tag should always be used on absolute URLs.
What do I use for unmatched languages?
In instances when you do not have a language or region that matches a user’s browser setting, you would use:
Using this value lets you control the user experience by letting you direct the user to the preferred page, such as your site’s homepage where the user can select their language or region of choice.
How do I fix hreflang errors?
The Language section: Monitor the usage and errors of hreflang tags on your site.
The Country section: Set a site-wide country target for your entire site, if desired.
You can also find several third-party tools. One of the most popular is Aleyda Solis’ hreflang Tags Generator Tool.
Some other ways to fix and/or prevent errors from popping up include:
- Updating page links when you delete a page.
- Changing hreflang URLS on pages linked to a page you have created a redirect for.
seoClarity's site audit technology, Clarity Audits, allows you to crawl your site and extract all the accompanying hreflang tags that are currently on your site to address the errors. Our built-in crawler identifies which pages may have hreflang tag issues. In addition, our SEO Professional Services team is also available to diagnose any issues you may be having with your site.
What are the most common mistakes to avoid with hreflang?
One of the biggest mistakes coders make is failing to use a valid hreflang tag. Watch out for the following:
- Missing confirmation links. If page A links to page B, page B must link back to Page A. Google cautions that if you do not follow this linking structure for all hreflang annotations, the annotations may be ignored or incorrectly interpreted.
- Incorrect language codes. Use the ISO 639-1 format for language codes. This is the standardized nomenclature used to classify languages. A comprehensive list is available on Wikipedia. Remember, using only a region code is not sufficient. If you use a region code you must also use a language code.
Our SEO Professional Services team put together an in-depth list of common hreflang mistakes.
Next Steps for Better Global SEO
Keeping in mind that hreflang is a signal, not a directive, there are other factors to consider that may override your tag and cause a different version of your page to rank higher. Some of these international SEO best practices are:
- Linking to local content
- Hosting your site on a local IP
- Building links for local resources
- Connecting with local search engines
Even if you do implement any of these international SEO practices, using hreflang tags is a valuable tool for global SEO as it gives search engines a clear signal as to which pages are for users in a specific language or region.
Editor's Note: This post was originally published in June 2016 and has been updated for accuracy and comprehensiveness.