Skip main navigation

Hreflang Tags

Hreflang tags help Google understand the localized pages of your site. Learn more about how they work in this article from Peter O'Callaghan.

Hreflang tags tell Google about the international equivalents or versions of your content so that they can understand that these pages are localized variations of the same content. They can be added to either your sitemap, into the page’s HTML, or into the HTTP headers of each page. You only need hreflang tags if a page has international equivalents of itself. If you’re creating many localized versions of your site, it’s recommended to go with putting hreflang in your sitemap as it’s easier to manage and audit, but any of the options will work.

In this example we’ll show you an example of HTML tags that go directly onto the webpage.

Here’s a template of a hreflang tag:

 <link rel="alternate" hreflang="**lang_code**" href="**url_of_page**" />

Variables in this tag:

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 an hreflang tag on the page.

The value of the hreflang attribute identifies the language and, optionally, a region of an alternate URL. If there’s only one code specified, Google assumes the code to be a language code. The language doesn’t need to be related to the region. For example:

de: German language content, independent of region

en-GB: English language content, for GB users

de-ES: German language content, for users in Spain

url_of_page

The fully-qualified URL for the version of this page for the specified language/region.

You add hreflang tags for all the international equivalents or versions of a page so the set of tags tells the search engine where to find all of the localized versions and in which country to rank them.

Here’s an example of some hreflang code that you might see on the homepage of a site’s HTML head section:

 <link rel="alternate" hreflang="**en-US**" href="https://yoursite.com/" />

<link rel="alternate" hreflang="**en-GB**" href="https://yoursite.com/en-gb" />

<link rel="alternate" hreflang="**de-DE**" href="https://yoursite.com/de-de" />

<link rel="alternate" hreflang="**es-ES**" href="https://yoursite.com/es-es" />

<link rel="alternate" hreflang="**fr-CA**" href="https://yoursite.com/fr-ca" />

<link rel="alternate" hreflang="**ca-ES**" href="https://yoursite.com/ca-es" />

<link rel="alternate" hreflang="**es-MX**" href="https://yoursite.com/es-mx" />

<link rel="alternate" hreflang="x-default" href="https://yoursite.com/" />

The snippet above tells Google to target the .com/ homepage (without a language subfolder) at English speakers in the USA, the en-gb homepage at English in the UK, de-de homepage at German in Germany, es-es homepage at Spanish in Spain, fr-ca homepage at French in Canada, ca-es homepage at Catalan in Spain, es-mx homepage at Spanish in Mexico, and finally, if none of those match the user’s language country combo, then show the .com/ homepage.

There’s a full set of guidelines that these tags need to conform to. For example, each language version must list itself as well as all the other language equivalents of that page.

If your strategy’s structure is to target just languages without specifying countries, then you don’t need hreflang tags as Google uses its algorithms to detect the language of a page and will understand that you want that language version to target people searching in that language. Hreflang tags are more for if you’re going to target specific countries.

Google doesn’t use hreflang or the HTML lang attribute to detect the language of a page; instead, they use algorithms to determine the language. So if you’re going with just language targeting, you can skip the hreflang tags.

It’s worth noting that sometimes Google will rank the wrong country version in the wrong region if it thinks it knows better. This sometimes happens if the original version of your site has more powerful backlinks than your new localized version, or if you have too many versions that are similar to each other.

How to remedy this? Check if the right user is on the right regional site by looking at their ip address. If they’re not on the right version, serve them a pop-up asking them if they want to switch to the regional version of their site.

Don’t try to implement automatic geo-ip redirects. This is a technical SEO recipe for disaster because Google only crawls from the USA, and it will never see your new shiny local versions of your website if you’re always geo-ip redirecting it back to the USA site.

This article is from the free online

Localization for Marketers

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now