Skip to content
All articles

What is hreflang, and how do you set it up correctly?

guide // , 4 min read, by Darthwares

Hreflang is an attribute used to tell search engines and browsers about different language or regional versions of a web page. Its purpose is to help Google Search direct users to the most suitable version of your content based on their language or location. Correct setup involves specifying all localized variations and ensuring reciprocal links between them. If these return links are missing, the hreflang tags will be ignored.

A diagram showing three web pages, one in English, one in Spanish, and one in French, with arrows indicating that each page links to itself and all other language versions using
On this page // 7 sections
  1. 01What is hreflang?
  2. 02Why should you use hreflang?
  3. 03How do you implement hreflang?
  4. 04What is the return-link rule for hreflang?
  5. 05What are common hreflang attribute values?
  6. 06How do you check hreflang implementation?
  7. 07Common questions

The short version

  • Hreflang informs search engines about localized page versions.
  • It helps users find content in their preferred language or region.
  • Each localized page must link to itself and all other versions.
  • If return links are missing, hreflang tags are ignored.
  • The attribute value uses BCP 47 language tags, optionally with a region.

What is hreflang?

Hreflang is an attribute that indicates the language and geographical targeting of a web page. It is part of the HTML <link> element, which specifies relationships between the current document and an external resource. This attribute tells search engines, such as Google, about different localized variations of your content.

Why should you use hreflang?

Using hreflang helps Google Search direct users to the most appropriate version of your page. For example, a user searching in Spanish might be shown the Spanish version of your page, even if an English version is also available. MDN Web Docs notes that this hint can be used by browsers to select the more appropriate page or to improve SEO.

How do you implement hreflang?

Hreflang is implemented as an attribute within the <link> HTML element. MDN Web Docs states that this attribute indicates the language of the linked resource and should only be used when the href attribute is also present. The hreflang property of the HTMLLinkElement interface reflects the hreflang attribute of the <link> element and is an empty string if there is no hreflang attribute.

The attribute's value consists of one or, optionally, two parts, separated by a dash. MDN Web Docs specifies that these values should be valid BCP 47 language tags. For instance, "en" indicates English, while "en-GB" specifies English for Great Britain.

A critical rule for hreflang implementation is the "return-link" or reciprocal linking requirement. Google documents that each language version of a page must list itself as well as all other language versions. This means if page X links to page Y using hreflang, then page Y must also link back to page X.

If two pages do not both point to each other, Google states that the hreflang tags will be ignored. This reciprocal linking ensures that Google can confirm the relationship between the localized pages and correctly understand them as variations of the same content.

What are common hreflang attribute values?

The hreflang attribute's value uses BCP 47 language tags, which can specify a language, or a language combined with a region. This allows for precise targeting of content.

Examples of hreflang attribute values
ValueMeaning
enEnglish (any region)
esSpanish (any region)
frFrench (any region)
en-USEnglish for the United States
en-GBEnglish for Great Britain
es-MXSpanish for Mexico

How do you check hreflang implementation?

Ensuring correct hreflang implementation can be complex, especially with many localized pages. Google notes that many third-party tools are available that you can use to debug hreflang annotations. These tools can help identify issues such as missing return links or incorrect language tags, which would otherwise cause the hreflang tags to be ignored.

Common questions

What is the main purpose of hreflang?

Hreflang tells search engines about different language or regional versions of a page. Google states this helps Google Search point users to the most appropriate version of your page by language or region, understanding that these pages are localized variations of the same content.

What happens if hreflang links are not reciprocal?

Google documents that if two pages do not both point to each other, the hreflang tags will be ignored. Each language version must list itself as well as all other language versions to ensure proper recognition.

What format do hreflang attribute values use?

The hreflang attribute's value is comprised of one or optionally two values, separated by a dash. MDN Web Docs specifies that these values should be valid BCP 47 language tags.

Can hreflang improve SEO?

Yes, MDN Web Docs states that the hreflang property can be used by browsers to improve SEO. By directing users to the most relevant localized content, it enhances the user experience and can positively impact search visibility.

Where is the hreflang attribute used?

The hreflang attribute is used within the HTML <link> element. MDN Web Docs explains that this element specifies relationships between the current document and an external resource, and the hreflang property reflects this attribute.

Primary sources and further reading

This article was researched and written by an AI model and published automatically. It was written from sentences that were checked to appear on the pages below, but a person has not reviewed the text. If something is wrong, tell us at chibivikramathithan@darthwares.com and we will correct it.