Hreflang

From Seobility Wiki
Jump to: navigation, search

Definition

hreflang
Figure: hreflang - Author: Seobility - License: CC BY-SA 4.0

hreflang is used when different languages ​​or contents with regional differences exist on a website. Its purpose is to tell search engines which URL to use for which language ​​and region. Thus, each page is assigned to the right country version of a search engine, ensuring that users from a particular country only see the pages that are relevant to them in search results. The attribute was introduced by Google in 2011 to better understand the international architecture of websites.


hreflang Checker

Check alternate and hreflang links on your web page

Application scenarios

Google recommends the use of hreflang in the following scenarios:

  • If pages have been translated completely into other languages, e.g. if there is a German, English and French version.
  • If most parts of a page are maintained in a particular language, but parts such as the navigation bar or footer are adapted to different languages. This is especially the case if pages contain user-generated content, e.g. in forums.
  • If several pages share the same language, but there are small regional differences such as different currencies or spellings. Example: There are two versions of an English page, one for users in the US and the other for users from the UK. In this case, it is especially important to use hreflang, as search engines might otherwise interpret the pages as duplicate content.
  • If individual pages have been translated or should only be accessible for certain languages ​​or countries, and the other users are to access a standard/default page.

Structure of the alternate link element

The hreflang annotation in the head section of an HTML document is structured as follows:

<link rel="alternate" hreflang="xx-XX" href="URL" />
  • <link opens the link element and indicates that there is a relationship between the current page and the specified URL
  • rel="alternate" tells search engines that there is an alternative version of the current document
  • hreflang="xx-XX": This attribute specifies for which language (xx) and, if applicable, for which region (XX) the following URL should be displayed. Languages must be indicated in ISO 639-1 format and countries in ISO 3166-1 Alpha 2 format.
  • the attribute href="URL" specifies the URL of the alternative version of the current document
  • /> closes the link element

For example, if you have a German web page and you want to refer to the English version of it, you have to use the following code:

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

Implementation

As already mentioned, hreflang can be used in a link element in the head area of ​​the HTML code. However, this is not possible if the file is not saved as an HTML file but as PDF, for example. In this case, you have two options:

1. Specification in HTTP response header:

Link: <http://www.example.com/>; rel="alternate"; hreflang="en"

2. Specification in an XML Sitemap:

This variant is particularly suitable for very large websites with many different language versions since it can limit the effort of implementing the hreflang annotation here. In this case, an xhtml:link element must be added to each URL element of the sitemap:

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

Which of these three alternatives you should use depends on the size and structure of your website.

How to use hreflang correctly

You should consider the following aspects when using alternate links:

  • Basically, each page that contains alternate links also has to link to itself, i.e. on a German web page, the HTML code must also refer to the German version of this page.
  • In addition, each referenced page must link back to the referring page. This means that if a German page refers to the English version of this page, the English page must also refer back to the German version (bidirectional linking, see figure above). Otherwise, Google may ignore or misinterpret the hreflang annotation.
  • In addition, you have to ensure that the language or country codes are correctly specified in accordance with the ISO standard. Although it is possible to only specify a language, the sole indication of a country is invalid. The capitalization of country codes is not necessary.
  • If a web page only offers alternate page versions for certain languages ​​or countries and the other visitors are to be directed to a standard page, this general page can be defined with the attribute value hreflang="x-default".

Indirect Relevance of hreflang for Search Engine Optimization (SEO)

Although the use of hreflang is not a direct ranking factor, it can indirectly impact the search engine optimization (SEO) of a website. For example, if hreflang links are missing or not implemented correctly, search engines might consider the content of two alternative language versions as duplicate content, which can have a negative effect on the SEO and ranking of these pages.

Furthermore, using hreflang correctly will result in each user receiving only relevant search results, which will improve their user experience. This, in turn, can increase dwell times and reduce your bounce rate, which will positively impact your SEO and Google's evaluation of your page.

However, you should bear in mind that alternate links are only an indication to Google which can also be ignored. Thus a positive impact on SEO can not be guaranteed.

Related links

Similar articles