By Tracy Mu Sung
In our previous blog post, Multilingual SEO Tips – Part 1 – Geo-Targeting – we mentioned the hreflang tag but didn’t go into details on how to use it. Instead, the post talked about lot of things about geo-targeting and how to improve your rankings for particular languages (or in particular countries). It didn’t, however, get into the issue of this ‘relatively’ new markup tool from Google, the hreflang Rel Alternate.
The hreflang link element provides a connection between the various language versions of individual pages on your site and allows Google to swap the URLs currently shown in the search results with ones that are more relevant to the user. It does not affect the ranking of your site.
For example, if Google shows www.mysite.com/en/page1.html at rank 10, putting a href lang tag on that page for German doesn’t mean this page will necessarily rank higher in Germany, or for German language users. It just means that Google won’t show the German users the /en/ page. Instead, Google will deliver www.mysite.com/de/page1.html.
You might wonder why you can’t just use rel=canonical on your language pages? Google doesn’t recommend this, particularly now that it has dedicated markup for language. Using rel=canonical within a particular language version of your site is fine, but not instead of hreflang.
How to Use Rel Alternate Hreflang
The hreflang tag is used at a page level, not site level. For every page that has multiple language versions, you need to assign appropriate code. This can be on each individual page, or you can do it in your XML sitemap.
Hreflang on your pages
If your site is in German and English, then each page will have 2 extra lines of code in the <head> section of your pages:
<link rel=”alternate” hreflang=”en” href=”http://www.example.com/en” >
<link rel=”alternate” hreflang=”de” href=”http://www.example.com/de” >
This code must go on both http://www.example.com/en and http://www.example.com/de
There is no limit to the number of alternative pages you have. You can even do it for versions of the same language in different countries. For example, if you want to have dedicated content for English speakers in US versus English Speakers in Australia. You can find a list of language/location codes here.
Hreflang in Sitemaps
If you would rather, you can instead change your XML sitemap, to be set out like this:
If you use the XML sitemap version, you must update the opening of your XML sitemap to be;
<?xml version=”1.0″ encoding=”UTF-8″?>
Finally, if you publish non-HTML files (E.g. PDFs), you can use an HTTP header
Link: <http://es.example.com/>; rel=”alternate”; hreflang=”es”