What is Hreflang?
Hreflang is an HTML attribute that tells search engines about the different versions of a page tailored for various languages or regions. This helps Google deliver the correct localised version to users.
You can apply the hreflang attribute in three ways:
- HTML tags
- HTTP headers
- Sitemaps
What Is an Example of a Hreflang?
An example of a hreflang tag is as follows:
<link rel="alternate" href="https://example.com/fr/" hreflang="fr" />
This tag indicates that the URL “https://example.com/fr/” is the French version of the page. The hreflang="fr"
attribute tells search engines to serve this version of the page to users searching in French.
Importance of Hreflang for SEO
Hreflang is important for SEO because it helps search engines identify and serve the appropriate localised version of your pages based on the user’s language and/or region.
It’s key to international SEO, especially when expanding your online presence across multiple countries. Additionally, hreflang pages share each other’s ranking signals, which can impact your search rankings.
According to Google’s Gary Illyes, the page that best matches the search query will determine the ranking position, but the most relevant page for the user will be shown in the SERPs. Therefore, hreflang tags can have a direct influence on your rankings.
Additionally, hreflang is an effective way to resolve duplicate content issues on your site. For instance, if you’re targeting audiences in the US and UK with two different versions of the same page—where only minor differences like spellings and currencies exist—the rest of the content would be identical.
By using hreflang, you signal to Google that these are two distinct versions. Without it, Google might view these pages as duplicates and index only one, leading to losing visibility and traffic for the other.
Hreflang Best Practices
Always Use a Self-Referencing Hreflang Tag
When applying hreflang tags to a page, ensure each page includes a self-referencing hreflang link. This means the page must reference itself and the alternate versions.
For example, if your site has English and Italian versions of a page:
- English:
https://example.com/hello
- Italian:
https://example.com/ciao
The English version should include the following hreflang tags:
<link rel="alternate" hreflang="it" href="https://example.com/ciao" /> <link rel="alternate" hreflang="en" href="https://example.com/hello" />
While some SEOs consider this an optional practice, Google’s guidelines recommend it as essential.
Ensure Valid Language and Region Codes
Googlebot identifies the hreflang attribute using language and region codes. The language code must follow the ISO 639-1 format, and the region code should adhere to the ISO 3166-1 Alpha 2 format.
The language code is mandatory, while the region code is optional. If only one code is specified, Google assumes it’s the language code. Therefore, it’s crucial to use the correct format for these codes.
For instance, if you’re targeting the UK, the correct language-location code is en-gb
, not en-uk
.
Add an “x-default” Tag for Unmatched Languages
The x-default
hreflang tag informs Google that the page should be shown to users whose languages are not specified in the hreflang tags. It acts as a fallback page for unmatched languages.
While not mandatory, Google recommends using the x-default
tag. It looks like this:
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
Ensure Identical Hreflang Tags Across All Page Versions
To maintain accuracy, the set of hreflang tags should be identical across all page versions. This means every group page must include the same set of hreflang links.
For example, if your blog homepage has six language versions, each localised version should include the same set of seven hreflang links (six languages plus the x-default
).
Frequently Asked Questions
What Is the Difference Between Href and Hreflang?
Href is an HTML attribute used in <a>
tags to link to other pages or sections. For example:
<a href="https://example.com">Visit Example</a>
Hreflang is an attribute used in <link>
tags to indicate the language and regional targeting of a page. It’s essential for websites with localised content to ensure users see the correct version of the page. For example:
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
How to Generate Hreflang Tags?
- Identify Codes: Use ISO 639-1 for language (e.g., “en”) and ISO 3166-1 Alpha 2 for region (e.g., “GB”).
- Create Tags: For each page version, add a
<link>
tag with the correcthreflang
value. - Use x-default: Include an
x-default
tag as a fallback for unmatched languages. - Validate: Ensure tags are correct using tools like Google Search Console.