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.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Jiří Vaněk
I’m using PolyLang and now it seems like the PolyLang plugin itself has resolved it. Without any other plugin for hreflang, I have both languages in the source code, Czech and English.
WPBeginner Support
Glad to hear the plugin solved this for you
Admin
Daniele
Hello there,
I have my main website in English but I want to create an Italian version of it. I just create a subdirectory of it named example.com/it and installed WordPress on it.
Do I have to install the plugin described in the second method on my main website or the it one?
thanks
WPBeginner Support
If you did that, you would want to use the second method. We would normally recommend using the first method for most users to be easier to maintain.
Admin
Miguel
In my specific case I need to implement “hreflang”, or is Not necessary since I’m using completely different domain names ? ?
WPBeginner Support
While in some cases it can be helpful, if you are using completely different domains then it is not required to use the hreflang tag.
Admin
Navneet Siddhartha
Thank you so much for writing this article. This really help me a lot…..Thank you..
WPBeginner Support
You’re welcome
Admin
shan ullah
its a real world help i thank full to you for this information i will definitely apply it on my website
WPBeginner Support
Glad you’ll use our content
Admin
Erez
you can set up the language on the WordPress setting page.
WPBeginner Support
Correct, the hreflang tag is for if you use more than one language on your site.
Admin
Nasir
Can we use hreflang code on a large site which has been targeting more than 80 regions? does it not increase the website load time?
Dani
I already applied for a sitemap but I went through superb tutorail of your about herglang tag tell me now I have to again go for sitemap ? or it will automatically upload it
Shyamu
I have been trying to add this hreflang tags in my site. But after adding the tags for a particular targetting country. Its still showing the “en-un” return error. How to solve this in Google Search Console?
Bhavya
Hi,
I am working on a multilingual website. How many lagnuages i can target at once?
Mudassar
Hi, I am using English US in my Wordpress and my content is also in English but even then Google Webmaster shows this message
“Your site has no hreflang tags”
My domain ends with .pk.
Should i insert the following in header.php of my theme?
If not, what i should do then?
Thomas Greenbank
If you are only writing for one language or region you can ignore the “no hreflang tags” message.
That message will appear automatially, but just ignore it.
didmin
I got question
I am building a Germany website, after add my site into Google Search Console, it is showing me ” no hreftag” error
My site is only targeting Germany speaking countries, and only in Germany language, so what should I do ?
Please help me, very urgent!
Sam Jaff
Yes it will show ” No hreflang ” because you using online single language (Germany) on your website. If you want to target other countries then you have to make settings as mention up on this blog. So it will show in other language to target other country people. But as you said you just want to target German people then don’t consider hreflang and move forward.
Pitshou Beya
If I have to use hreflang tags, do I have to translate manually each post? Or just implement the tag on the post
Mitesh
Does the default lang=”en-us” have SEO factor that google will consider it to display more to USA visitors and less to other countries?
Will changing to lang=”en” can benefit targeting
Alice Miller
Hello,
I am not using any specific lang tag for my website. As you told before that WordPress add html lang=”en-US” by default. I checked it’s there in my website. but whenever i am going through any tools there showing it’s missing. Please can you tell me what could be the error
Olaniyi
Hi, I’m not targeting a particular country, do I still need to implement hreflang?
Thomas Greenbank
Thanks for posting this.
If I have a post on a .com site that I want to target to en-au audience, do I need to have an en-us version also? What I mean is, can I have some posts on my site targeting US visitors and others targeting Aus visitors without duplicating them?
Thanks in anticipation.
Thomas.
Khemraj
Hello,
Suppose I have .com domain and i want to target it to countries like us, uk , canada, australia etc. If i created sub directory like example.com/us, example.com/in etc so to target specific countries do i need to install wordpress in each subdirectory ? ? ?
Nick
I wanna know if my site only one language, did I need to input this Hreflang Tags?
WPBeginner Support
Hi Nick,
No, you don’t need hreflang tags. WordPress automatically adds the default language in the html tag like this:
<html lang="en-US">
Admin
Mitch
If you are only targeting one single language is there an SEO benefit for doing a Hreflang Tag or can it just be left unset?
amihan
what about codes?? nice functions of wordpress are not enought?
Rowels Brutte
Hello.
An informative post on hreflang attribute.
I am trying to implement it from a long time.
But for example, if I want to have 3 different pages for the same language but different country like en-gb, en-us, en-au, how do I proceed?
WPBeginner Support
As described in the article you can select them as hreflang in a multilingual plugin or hreflang tags lite plugin.
Admin