Localized Versions of your Pages | Google Search Central  |  Documentation  |  Google for Developers (original) (raw)

Stay organized with collections Save and categorize content based on your preferences.

Tell Google about localized versions of your page

If you have multiple versions of a page for different languages or regions, tell Google about these different variations. Doing so will help Google Search point users to the most appropriate version of your page by language or region.

Note that even without taking action, Google might still find alternate language versions of your page, but it is usually best for you to explicitly indicate your language- or region-specific pages.

Some example scenarios where indicating alternate pages is recommended:

Localized versions of a page are only considered duplicates if the main content of the page remains untranslated.

Methods for indicating your alternate pages

There are three ways to indicate multiple language/locale versions of a page to Google:

The three methods are equivalent from Google's perspective and you can choose the method that's the most convenient for your site. While you can use all three methods at the same time, there's no benefit in Search (in fact, it maybe be much harder to manage three implementations instead of just picking one).

Use hreflang to tell Google about the variations of your content, so that we can understand that these pages are localized variations of the same content. Google doesn't usehreflang or the HTML lang attribute to detect the language of a page; instead, we use algorithms to determine the language.

Guidelines for all methods

HTML tags

Add <link rel="alternate" hreflang="lang_code"... > elements to your page header to tell Google all of the language and region variants of a page. This is useful if you don't have a sitemap or the ability to specify HTTP response headers for your site.

For each variation of the page, include a set of <link> elements in the<head> element, one link for each page variant including itself. The set of links is identical for every version of the page.See the additional guidelines.

Here is the syntax of each link element:

Syntax
lang_code A supported language/region code targeted by this version of the page, or x-default to match any language not explicitly listed by anhreflang tag on the page.
url_of_page The fully-qualified URL for the version of this page for the specified language/region.

The <link> tags must be inside awell-formed section of the HTML. If in doubt, paste code from your rendered page into anHTML validator to ensure that the links are inside the <head> element. Additionally, don't combinelink tags for alternate representations of the document; for example don't combinehreflang annotations with other attributes such as media in a single<link> tag.

Example

Example Widgets, Inc has a website that serves users in the USA, UK, and Germany. The following URLs contain substantially the same content, but with regional variations:

URLs with regional variations
https://en.example.com/page.html Generic English language home page that contains information about fees for shipping internationally from the USA.
https://en-gb.example.com/page.html UK home page that displays prices in pounds sterling.
https://en-us.example.com/page.html US home page that displays prices in US dollars.
https://de.example.com/page.html German language home page.
https://www.example.com/ Default page that doesn't target any language or locale; it has selectors to let users pick their language and region.

Note that the language-specific subdomains in these URLs (en, en-gb, en-us, de) are not used by Google to determine the target audience for the page; you must explicitly map the target audience.

Here is the HTML that would be in the <head> section of all the pages listed in the URLs with regional variations table. It would direct US, UK, generic English speakers, and German speakers to localized pages, and all others to a generic home page. Google Search returns the appropriate result for the user, according to their browser settings.

Widgets, Inc

HTTP Headers

You can return an HTTP header with your page's GET response to tell Google about all of the language and region variants of a page. This is useful for non-HTML files (like PDFs).

Here is the format of the header:

Link: ; rel="alternate"; hreflang="lang_code_1", ; rel="alternate"; hreflang="lang_code_2", ...

Syntax
<url_x> The fully-qualified URL of the alternate page corresponding to the locale string assigned to the associated hreflang attribute. The URL must include surrounding < and> marks. Example: https://www.google.com
lang_code_x A supported language/region code targeted by this version of the page, or x-default to matches any language not explicitly listed by anhreflang tag on the page.

You must specify a set of <url>, rel="alternate", and hreflang values for every version of the page including the requested version, separated by a comma as shown in the following example. The Link: header returned for every version of a page is identical. See the additional guidelines.

Example

Here is an example Link: header returned by a site that has three versions of a PDF file: one for English speakers, one for German speakers from Switzerland, and one for all other German speakers:

Link: https://example.com/file.pdf; rel="alternate"; hreflang="en", https://de-ch.example.com/file.pdf; rel="alternate"; hreflang="de-ch", https://de.example.com/file.pdf; rel="alternate"; hreflang="de"

Sitemap

You can use an XML sitemap to tell Google all of the language and region variants for each URL. To do so, add a <loc> element specifying a single URL, with child <xhtml:link> entries listing every language/locale variant of the page including itself. Therefore if you have 3 versions of a page, your sitemap will have entries for the URLs of each version, and each entry will have 3 identical child entries.

Sitemap rules:

Example

Here is an English language page targeted at English speakers worldwide, with equivalent versions of this page targeted at German speakers worldwide and German speakers located in Switzerland. Here are all the URLs present on your site:

Here is the sitemap for those three pages:

https://www.example.com/english/page.html <xhtml:link rel="alternate" hreflang="de" href="" title="undefined" rel="noopener noreferrer">https://www.example.de/deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="de-ch" href="" title="undefined" rel="noopener noreferrer">https://www.example.de/schweiz-deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="en" href="" title="undefined" rel="noopener noreferrer">https://www.example.com/english/page.html"/> https://www.example.de/deutsch/page.html <xhtml:link rel="alternate" hreflang="de" href="" title="undefined" rel="noopener noreferrer">https://www.example.de/deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="de-ch" href="" title="undefined" rel="noopener noreferrer">https://www.example.de/schweiz-deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="en" href="" title="undefined" rel="noopener noreferrer">https://www.example.com/english/page.html"/> https://www.example.de/schweiz-deutsch/page.html <xhtml:link rel="alternate" hreflang="de" href="" title="undefined" rel="noopener noreferrer">https://www.example.de/deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="de-ch" href="" title="undefined" rel="noopener noreferrer">https://www.example.de/schweiz-deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="en" href="" title="undefined" rel="noopener noreferrer">https://www.example.com/english/page.html"/>

Supported language and region codes

The hreflang attribute's value is comprised of one or optionally two values, separated by a dash. For example, en-US. The first code of the hreflang attribute is the language code (in ISO 639-1 format) followed by an optional second code that represents the region code (in ISO 3166-1 Alpha 2 format) of an alternate URL.

To target different language speakers in Belgium, you might use the following language and region codes:

To simplify your labeling, you can specify a language code by itself. For example:

For language script variations, the proper script is derived from the country. For example, when using zh-TW for users in Taiwan, the language script is automatically derived (in this example: Chinese-Traditional). You can also specify the script itself explicitly using ISO 15924, like this:

Like with other language codes, you can also specify an optional region. For example, use zh-Hans-US to specify Chinese (Simplified) for users in the United States.

Use the x-default value for unmatched languages

The reserved x-default value is used when no other language/region matches the user's browser setting. This value is recommended for specifying the fallback page for users whose language settings don't match any of your site's localized versions. While you can use the x-default value for any page, it was designed for language selector pages and so it will work best with those.

There's no need to specify a language code for the x-default value; the page is targeted to users whose language settings are unmatched on your site, thus the language of the page is irrelevant.

To implement the hreflang="x-default" annotation, add an additionallink tag to the existing hreflang annotations, and set thehref attribute to the URL where you want your users to land if your site doesn't support their language. For example, an HTML implementation may look like this:

****

Troubleshooting

Common Mistakes

Here are the most common mistakes with hreflang usage:

Debugging hreflang errors

There are many third-party tools available that you can use to debug hreflang annotations. Here are a few popular tools. These tools are not maintained or checked by Google.