Do you want to add hreflang tags in your WordPress posts and pages? If you publish content in multiple languages or for different regions, then hreflang tag helps you improve SEO for those regions and languages. In this article, we will show you how to easily add hreflang tags in WordPress without writing a single line of code.
What is hreflang tag?
Hreflang tag allows you to tell search engines which page to show for a particular region and language. You can also use it to define other variations of the same content in different languages.
Here is how a hreflang tag implementation looks like in plain HTML.
<link rel="alternate" href="example.com" hreflang="en-us" /> <link rel="alternate" href="example.com/fr/" hreflang="fr-fr" /> <link rel="alternate" href="example.com/pt/" hreflang="pt-pt" />
The hreflang tag is a combination of the language code and the region code. For example, en-us for English and the United States, fr-fr for French and France, and so on.
WordPress is available in more than 60 languages, and you can use WordPress in your own language.
Many WordPress site owners target users in different regions and languages. Some do that by creating multilingual websites, while others do that by offering some content in other languages.
Search engines can easily detect the language of a page and automatically match it to the language settings on user’s browser. However, your pages may still be competing with each other in the search results which may affect your site’s SEO.
You can implement hreflang tags to fix that. Let’s see how to easily add hreflang tags in WordPress.
Method 1: Add hreflang Tag in WordPress Using a Multilingual Plugin
The best approach to building a multilingual WordPress site is by using a multilingual plugin. A multilingual WordPress plugin allows you to easily create and manage content in multiple languages using the same WordPress core software.
These plugins will automatically take care of all technical things such as the hreflang tag, so you can focus on creating content.
We recommend using Polylang. It is a free WordPress plugin and comes with a very powerful and easy to use interface to manage multilingual content. For detailed instructions, see our guide on how to how to easily create a multilingual WordPress site.
Another popular option is WPML. It is a premium WordPress plugin with an easy to use interface to create multilingual content on your website. For step by step instructions, see our guide on how to create a multilingual WordPress site with WPML.
After you have created some posts or pages in multiple languages, you need to visit them in a new browser window. Right click and select ‘View Page Source’ from your browser menu.
This will open the source code of the post or page. Now you need to look for hreflang tag to verify that it is working properly. You can also use CTRL+F (Command+F) keys to find the hreflang tag.
Method 2: Add Hreflang Tags in WordPress Without Using a Multilingual Plugin
This method is for users who are not using a multilingual plugin to manage translations on their websites.
First thing you need to do is install and activate the HREFLANG Tags Lite plugin. For more details, see our step by step guide on how to install a WordPress plugin.
Upon activation, the plugin will add a new menu item labeled HREFLANG in your WordPress admin menu. Clicking on it will take you to the plugin’s settings page.
Select the post types where you’d like to enable the plugin and then click on the save changes button to save your settings.
Next, you need to edit the post or page where you want to add the hreflang tag. On the post edit screen, you will notice a new metabox labeled HREFLANG tags.
First you need to add the URL of the post that you are currently editing and then select its language. After that you need to click on the plus button to add URLs of other variations of the post and their language.
Once you are done, click on save or update button to save your post.
You can now visit your post in a browser window and view its source code. You will see the hreflang tag added to your post.
We hope this article helped you learn how to easily add hreflang tag to your WordPress site. You may also want to see our step by step WordPress SEO guide for beginners.