After writing this I found out my approach was incorrect. I have since removed the code as it was not useful.
Dan’s team was kind enough to point me to Virgin Australia‘s site. If you inspect the source and search for hreflang, you’ll see how it should be done.
After seeing the excellent talk by Dan Petrovic at the Melbourne WordCamp, I went to find out more about the <link rel=”alternate” hreflang=”en-AU” href=”http://somesite.com.au/” />. He has an article describing it. Essentially if you have multiple sites that have similar content (but not exactly the same) then you can instruct google that the sites serve different regions by using the rel=alternate hreflang=”en=gb” options for the link tag.
A common scenario that you might find this useful would be in online stores where there is a different store for each country.
eg. for site somesite.com.au you want a <link> tag like this:
<link rel=”alternate” hreflang=”en-AU” href=”http://somesite.com.au/” />
and for somesite.com you might want a tag like this:
<link rel=”alternate” hreflang=”en-US” href=”http://somesite.com/” />
and you want to remove the rel=”canonical” option too.
I couldn’t find a plugin that would implement this in WordPress so I wrote one and put it up on github. Yoast does not have an option for this as far as I can tell.
At some point I might put it up on wordpress.org too if it seems like there is interest in it.
Setting alternate hreflang in WordPress
10 responses to “Setting alternate hreflang in WordPress”
I’ve been looking for plugin to help me implement rel=”alternate” hreflang markup. May i ask what was incorrect with your plugins, your description sounds about correct? Any plan to put ti back up in corrected?
Any plans to re engineer the plugin so it works correctly?
That’s a shame. I’m currently looking at a way of adding rel=”alternate using custom fields. Never coded wordpress before, nor am i a coder, so its a nice learning curve! Getting there though.
Did you ever find a solution to this or do you know of any plugins that do it?
I use Add Meta Tags plugin to fill in the hreflang entries per post. Since I use Yoast, I don’t use the description and title offered by Add Meta Tags, just their Full Meta Tags field for entering hreflang entries
Try this wordpress plugin: https://wordpress.org/plugins/language-selector-related/
I just installed it minutes ago, so can’t confirm but looks like just what i need. (I have 2 blog, each with the same content but with different language and on different domain.)