Everything you Need to Know about Hreflang

Here we describe the intricacies of Hreflang – a code presented to search engines to show them which pages of your website feature targeted content.


Ramzi Chamat / 8 Ways Media
2016-04-08 11:40:00

If you are running a website with similar content in multiple languages, then you need the most innovative technical solution around: hreflang. So, if you are a website owner who wants search engines to direct people to the most relevant, appropriate pages in the most relevant, appropriate language, hreflang is your answer.

What else can hreflang be used for?

Aside from language differences, hreflang can also be used to target people that use regional variations:

·         British English vs. American English

·         Dutch vs. German

·         Small differences (e.g. currencies, prices or spellings)

·         More apparent differences (e.g. country-specific information)

Hreflang is beneficial for many reasons. First of all, if you have a web page that has been optimised with the user’s language and location in mind, you want them to land on that specific page. Doing this improves the overall user experience and results in lower bounce rates, which in turn improves your rankings in Google.

Hreflang also comes in handy in the sense that it avoids the issue of duplicate content. Usually, if Google finds two very similar web pages with only minor differences in them (such as the change in currency) it will detect this as duplicate content which will affect your rankings. Using hreflang enables you to make it crystal clear to Google that, although these pages are very similar, they have actually been optimised for different audiences.

What exactly is hreflang?

Hreflang is a code presented to search engines in three different formats. Using the code, you specify to search engines which pages of your website feature very similar content targeted at different regions, or pages of your website featuring the same content in different languages. The content is embedded with annotations so that search engines can determine the most appropriate URL to present to users.

Why use hreflang?

As mentioned, hreflang is a fantastic resource for websites featuring the same content in different languages or similar content in regional variations. Whether or not your content resides on a single domain or multiple domains, it doesn’t matter. You can either link your variations within your single domain, or link between different domains.

The 3 Basic Rules of hreflang

1.       Valid attributes

Hreflang is a difficult spec to use if you do not know how to use it properly, and can take some time to get your head around. It’s essential to avoid falling victim to common traps.

The hreflang attribute needs to contain a value that consists of your chosen language, which can also be combined with a region if necessary. A language attribute must be in the correct ISO 639-1 format, which is a two-letter code.

On the other hand, the region should be in ISO 3166-1 Alpha 2 format (refer to this list for verification). It’s vital here that you use the correct region code, otherwise the region and language codes could get mixed up. 

2.       Return links

Every URL needs return links to another URL, regardless of the type of implementation being used. Regardless of how many languages are being used, you absolutely need to use return links.

3.       Link to self

Finally, we have self-links. Any hreflang link needs to link to the current page, otherwise, the implementation will fail to work.

How to Implement Hreflang

There are three ways to implement hreflang:

·         Using link elements in the <head>

·         Using an XML sitemap

·         Using HTTP headers

Technical specifics before implementing hreflang


There is a hreflang attribute value known as ‘x-default’. This attribute specifies which URL the user should be sent to if none of the languages that you have specified match their browser settings. So, in the event that a user’s language and location do not match any of the other attributes, they will be sent via the x-default attribute.

Useful tools when implementing hreflang

The hreflang tag generator

The hreflang tag generator is a great tool when generating link elements. Even when you are not choosing a link element implementation, it can still be useful to create some example code.

The hreflang XML sitemap generator

The hreflang XML sitemap generator, created by The Media Flow, can be used to feed a CSV with URLs on a per-language basis, which in turns creates an XML sitemap.

The hreflang XML tag validator

Once mark-up has been added to your pages, you should validate the mark-up (particularly if you are going to go to the link element in the <head> route). This tool, created by DejanSEO, is a great resource.

Anything else?

If you’ve done all of the above, congratulations! But you can’t stop there!

From here onwards, you need to perform regular audits on your implementation to ensure it’s running properly. Also, anyone who deals with content across your website must be made aware that you are dealing with hreflang:

·         If a page gets redirected the hreflang URLs on its counterparts must be changed

·         If a page is deleted its counterparts must be updated

As you can see, the hreflang process is not a straightforward one! For this reason, you need to understand the ins and outs in depth and stay up-to-date with any changes or updates, as they are announced! 

Interested to meet digital professionals?

Let’s discuss your project and try to find the best solution for your needs.