Let Link Software handle your WordPress updates, backups, and security for you. Packages start as low as $39/month.
How to Use Hreflang Tags on WordPress Multilingual Sites
Last Updated January 21st, 2022 · WordPress
When building a multilingual website, you should consider using hreflang tags. Hreflang tags are essential for multilingual search engine optimization. They can improve your website’s search engine rankings so that it generates more high-quality traffic. We’re going to discuss exactly what these tags are, how they work, and how you can add hreflang tags to your WordPress site.
Building a multilingual website, of course, requires the creation of multiple versions of your site’s pages. You’ll have to create a separate version for each language or country that you wish to target. With hreflang tags, you can specify these alternate versions. Search engines will use this information to serve the most relevant version to their users.
What Are Hreflang Tags?
Hreflang tags are Hypertext Markup Language (HTML) snippets that tell search engines the alternate languages and countries in which a page is available. Multilingual websites have pages in different versions. Hreflang tags define the languages and countries of these alternate versions for SEO purposes.
The hreflang attribute was invented by Google in 2011. Prior to its inception, Google struggled to serve pages from multilingual websites. It would often serve versions in a different language than that of its users. The hreflang attribute solved this problem by allowing webmasters to specify the alternate languages and countries in which their websites’ pages are available.
For example, if your website is available in English, Spanish and French, you can use hreflang tags to specify these three versions. Search engines will serve the English version for English-speaking users, the Spanish version for Spanish-speaking users and the French version for French-speaking users.
Benefits of Using Hreflang WordPress Tags
With hreflang tags, your multilingual website will become more accessible to users. Users who find your website through an online search query will encounter the version in their native language. As a result, they won’t have trouble navigating and engaging with your website. Hreflang tags improve accessibility by ensuring that search engine users encounter the right version.
Avoid Duplicate Content Issues
According to Gary Illyes, a webmaster trends analyst at Google, hreflang tags promote the sharing of ranking signals. In other words, all of the alternate versions of a page will rank in roughly the same positions and for the same searches. The alternate versions may feature content in different languages, but Google’s algorithm will treat them the same nonetheless.
Because they promote the sharing of ranking signals, hreflang tags eliminate SEO problems caused by duplicate website content. Alternate versions of a page are typically considered duplicate content. They have the same text; the text is just translated into a different language for each version. Without hreflang tags, search engines may filter some or all the alternate versions because they contain the same text.
When crawling a page on your multilingual website, search engines will inspect the HTML for an hreflang tag. If present, they’ll recognize the referenced versions as being the same but intended for users in different languages. Therefore, search engines won’t filter them as duplicate content.
Geo-target Your Posts
You can also use hreflang tags to target specific countries. The hreflang attribute supports both a two-letter language code and a two-letter country code. With a country code, the referenced version of a page will only be served to users in that country. Users located in other countries won’t see the page indexed in the search results.
Search engines can identify a user’s location through an Internet Protocol (IP) traceback. It’s an automated process that search engine algorithms perform in real time. When a user performs a search, the algorithm will look at the user’s IP address to determine where he or she is located.
Hreflang tags allow you to restrict the search engine visibility of your website’s pages to specific countries. An alternate page version with the country code “fr” will only show for users located in France, whereas a version with the country code “ca” will only show for users located in Canada. You can give any alternate page referenced in an hreflang tag a country code and a language code.
How to Create Hreflang Tags on a WordPress Site
Adding hreflag tags to your WordPress site is a relatively simple task that can be done in one of two ways. You can edit your WordPress theme and your sitemap on your own. Or you can use a WordPress hreflang plugin to have the work done for you.
The “Do It Yourself” Solution
Interested in some DIY website editing? You can create hreflang tags by adding them to your WordPress theme’s HTML. In the head section, add an hreflang tag referencing the alternate versions and their respective language or country.
Here’s an example of an hreflang tag for a Spanish version of a page that targets users in Mexico.
<link rel="alternate" hreflang="es-mx" href="https://example.com/es/spanish-version-of-page" />
You’ll need to create an hreflang tag for each template with at least one alternate version. The hreflang tag should reference all alternate versions as well the page containing the hreflang tag. If you’re creating an hreflang tag to specify the Spanish version of an English-language homepage, you should reference the URLs of both the Spanish and English versions.
Keep in mind that hreflang tags often require updating. If you add a new version of a page, you’ll have to edit the hreflang tags inside your WordPress templates. You’ll need to add the URL, as well as the language or country, of the new version to all of the other pages’ hreflang tags.
You can create hreflang tags using a sitemap as well. In an Extensible Markup Language (XML) sitemap, use the “xhtml:link” attribute to reference the alternate versions of your website’s pages. For more information on how to create hreflang tags in an XML sitemap, visit Google’s help article.
Using a Hreflang Tag WordPress Plugin
Let’s be honest. This is the practical way to go for 99% of people reading this article. The WordPress community has put together a handful of plugins that handle hreflang tags automatically.
HREFLANG Tags Lite
The HREFLANGS Tags Lite plugin, available for free on the WordPress.org plugin repository, is one of the simpler choices. This plugin offers a meta box interface for posts, pages, and categories to manage your tags. It also supports WordPress multisite out of the box. There is a Pro version of the plugin, with additional features, but we recommend starting with this free release first to see if it meets your needs.
Polylang is a WordPress plugin built specifically for creating multilingual WordPress sites. It comes with a whole suite of features around maintaining and even translating content in multiple languages. Support for hreflang tags is built right into Polylang so you can use this plugin and not have to worry about your own implementation.
Finally, WPML is the biggest player in the WordPress language space. This plugin is not free and offers more features than you might need, but it is a top-of-the-line piece of software. You can have WPML generate and maintain your hreflang tags inside of your WordPress site for you automatically. In addition, WPML comes with very powerful translation tools if you need extra help in converting all of your existing and new content.
Need Help with Hreflang WordPress Tags?
Not all websites need these tags. Hreflang and WordPress are only necessary if you are producing content in multiple languages. Those that are available in a single language won’t benefit from these snippets. For multilingual websites, however, hreflang tags are essential. They’ll help search engines serve the correct version to their users while also preventing potential SEO problems caused by duplicate website content.
Link Software offers WordPress development services and SEO consulting to all of its clients. If you have any questions about hreflang tags, or WordPress in general, please reach out to us for help.