International websites often have similar content for different language groups and countries. The hreflang tag is an HTML tag communicating the language targeting of single pages to Google. This does not only ensure correct indexing but also avoids problems with issues are caused for example if the same content is provided for German speaking users in Germany and Switzerland using different URLs.
This does not only ensure correct indexing but also avoids problems with duplicate content. These issues are caused for example if the same content is provided for German speaking users in Germany and Switzerland using different URLs.
There are two possibilities to implement the hreflang tag – Google equally supports both options:
- In the <head> section of the website
- In the sitemap
The example below is based on a website with the following language and country versions:
The website is in English (“global/en”) and German (“global/de”). In addition, for the target market Switzerland there is specific content in the subfolders “/ch/en” (English) and “/ch/de” (German). Users who do not speak English or German should see the pages in “/global/en” (default).
1. Implement the hreflang tag in the <head> section of the website
The hreflang tag has to be added within the <head> section on every page of the website. The following example shows the tag for the home page. It is important to keep in mind that it has to be defined for every subpage.
The ISO 639-1 format is supported for the language values and the ISO 31661-1 Alpha format for the country specifications. (ISO 639 defines the identifiers for the names of language codes. ISO 3166-1 Alpha-2 codes are two-digit country codes used to represent countries, dependent territories and special territories of geographical interest.)
<link rel=”alternate” href=”website.com/global/en” hreflang=”x-default” />
<link rel=”alternate” href=”website.com/global/de” hreflang=”de” />
<link rel=”alternate” href=”website.com/ch/en” hreflang=”en-CH” />
<link rel=”alternate” href=”website.com/ch/de” hreflang=”de-CH” />
The value “x-default” defines that this version of the page should be the default version, for users who do not speak any of the defined languages. All German speaking users are meant to use the version “/global/de”, except the ones located in Switzerland: For these users the content is provided as “/ch/de” (German) and “/ch/en” (English).
2. Implement the hreflang tag in the sitemap
Alternatively, these specifications can be defined in the sitemap. In this case each URL needs to be listed separately as well. An example sitemap with hreflang information can be found on the Google support pages.
3. Monitoring the hreflang tag
Once the hreflang tag is implemented, possible errors are displayed in the Google Search Console “International Targeting Report”. They can be found in the tab “Language” on the report.