Localized pages markup

Sites that provide several language versions of a document can let Yandex know about these versions with the hreflang attribute. The Yandex robot uses the value of this attribute to choose the page version shown to a certain user in the search results.

We recommend to use the hreflang attribute if:

  • The page versions differ only in the template language. This works, for example, for sites with user content. A forum post or a blog entry text usually remains the same, while the navigation elements, the header and the footer can be displayed in different languages.

  • The page versions are in the same language but they differ in small details. For example, slightly different English texts can be addressed to users in the United States, Ireland and Australia.

  • Each page version is a complete and accurate translation of the page in the main site language.

Localized pages markup

Each page version must contain information about all versions.

Page versions can be located in different subdomains and domains. For example, a page on the ru.example.ru site is duplicated in English (en.example.ru) for Americans and in Turkish (example.com.tr) for Turks. Each of the pages should contain three <link> elements with localization attributes:

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

The hreflang attribute must contain the page language and the region, if needed. The attribute in this example is interpreted as follows:

  • “ru” — A page in Russian.

  • “en-us” — A page in English for users in the USA.

  • “tr-tr” — A page in Turkish for users in Turkey.

The site structure doesn't affect the processing of the hreflang attribute. Page versions can be located in different directories.

<link rel="alternate" hreflang="ru" href="http://example.com/o-kompanii/" />
<link rel="alternate" hreflang="en-us" href="http://example.com/company/about/" />
<link rel="alternate" hreflang="tr-tr" href="http://example.com/firma-hakkinda" />

You should specify the language and region according to the ISO standard:

In addition to the <link> element, you can use the Link header in the HTTP response to specify language and region, for example:

Link: <http://ru-ru.example.com/>; rel="alternate"; hreflang="ru-ru"

Pages with automatic language detection

If there are site pages where the language is determined by the user settings (Accept-Language, IP), or pages featuring a language selector, specify them along with other localized documents. Let's assume that the home page example.ru from the example above changes the language depending on the user IP address. You should indicate it by setting the hreflang attribute to x-default.

<link rel="alternate" hreflang="x-default" href="http://example.com/" />
<link rel="alternate" hreflang="ru" href="http://example.com/o-kompanii/" />
<link rel="alternate" hreflang="en-us" href="http://example.com/company/about/" />
<link rel="alternate" hreflang="tr-tr" href="http://example.com/firma-hakkinda" />