Hreflang Tag

The hreflang tag (also referred to as rel="alternate" hreflang="x") tells Google which language you are using on a specific page, so the search engine can serve that result to users searching in that language.

Code Sample

<link rel="alternate" href="http://example.com" hreflang="en-us=" />

What is Rel="Alternate" Hreflang="x"?

Introduced by Google in December 2011, the hreflang tag allows you to show search engines what the relationship is between web pages in alternate languages. It's useful when you've created content that's specific to a local audience. The hreflang tag adds a signal to search engines that a user querying in language "x" will want this result instead of a page with similar content in language "y".

For example, if you create a Spanish-language version of your English-language homepage, you would tag it as "Español" by using hreflang="es" so that searchers with an IP address that a search engine has reason to believe is in a Spanish-speaking country are served that page in Spanish instead of the English version. This can decrease your bounce rate and increase your conversions by making sure your target audience lands on the version of your page most appropriate for them.

Hreflang can also be used to show that you have content targeted toward variants of a single language. If that's the case, you can target your pages even more specifically by extending the hreflang tag with annotations that indicate which region the content is localized for, e.g. Spain (hreflang="es-es") versus Mexico (hreflang="es-mx"). This is particularly useful to geotarget users to control for variations in currency, shipping, seasonality, and culture.

Hreflang is a signal, not a directive. That means that other SEO factors may override the hreflang tag and cause a different version of your page to rank higher. To give search engines the clearest possible signals about which pages are for users in which language, make sure you're using other international SEO best practices.

Note that while Google and Yandex currently use the hreflang tag, Bing uses language meta tags instead.

SEO Best Practices

To get the most benefit out of the hreflang tag, the following tips are important:

Where the Hreflang Tag Goes

The hreflang tag can be placed in the on-page markup, the HTTP header, or the sitemap. Only use one of those locations. If you choose the sitemap, this tool can help you.

What the Hreflang Tag Looks Like

The hreflang tag on each page should include a reference to itself as well as to all the pages that serve as alternates for it. If your Spanish website sells Iberian ham to customers in Spain, France, and Portugal only, the hreflang tags for your homepage might look like this:

The same annotations should appear on your French and Portuguese homepages.

It is still possible that Mexican, French Canadian, and Brazilian customers could see your site (remember, hreflang is a signal not a directive), but if you localize other aspects of your content and site (start by indicating what currency you use and showcasing a local address and phone number), you're less likely to have to deal with pesky American import/export restrictions on your meat products :).

ISO Language and Region Codes

Image from a blog post by Aleyda Solis showing how frequently the wrong hreflang tag is used.

Google supports the ISO 639-1 format for language codes, and you can get more specific by using the ISO 3166-1 Alpha 2 format to signal which region you're targeting. Not all of the codes are intuitive (for example, the code for the UK is "gb" not "uk"), so double check before pasting the wrong code all over your site. This hreflang tag generator can help.

You can use multiple hreflangs on one page if you want to show that the page is for users in more than one country or area. For example, if the page targets people who speak Amharic in both Ethiopia and Eritrea, you can indicate that like this:

Hreflang's Effect on Rankings

Hreflang tags may not help you increase traffic; instead, the goal of using them is to serve the right content to the right users. They help search engines swap the correct version of the page into the SERP based on a user's location and language preferences. For information on how geotargeting can help with rankings, learn about ccTLDs.

The Difference between Hreflang and Canonicalization

Canonicalization is a tool for showing search engines which version of a URL (each with the same content) is the dominant one to avoid duplicate content issues. Hreflang, on the other hand, is a tool to show which of the different (but often similar) pages (based on language or region) should show up in a search.