More topics

hreflang

In brief

HTML attribute that tells Google which language version of a page applies to which region. Important for multi-language or multi-region websites.

hreflang is an HTML attribute that tells Google and Yandex which language version of a page is meant for which region. If you run multilingual or multi-region sites, you will need it.

Where to add hreflang

There are three options. First, as a link element in the head of every page with rel alternate and the hreflang code plus href. Second, in the HTTP header for non-HTML files such as PDFs. Third, in an XML sitemap with xhtml:link entries. The HTML option is the most common and the easiest to maintain.

Setting language codes correctly

The language comes from ISO 639-1, so de for German and en for English. Optionally add a region from ISO 3166-1, so de-DE for German in Germany and de-AT for German in Austria. There is also the special code x-default for the default version when no region matches. If you have several regions with the same language, you should list all variants plus x-default.

Reciprocity is mandatory

hreflang has to work in both directions. If your German page points to the English one via hreflang, the English page must also point back to the German one via hreflang. Otherwise Google ignores the annotation. This is the most common source of hreflang errors.

Who does not need hreflang

Anyone with only one language. Anyone serving only one region. Anyone with no genuine language versions of a page, only different content for different markets. In that case a simple canonical tag is enough, possibly combined with automatic redirection via IP geolocation, although Google takes a critical view of that.

Related terms

Canonical tag · Sitemap · Title tag

Want to improve your website?

We analyse your site and tell you honestly what is worth fixing. The initial consultation is free.

Free initial consultation