What are Hreflang Tag Attributes And How To Implement Them

Updated by Chima Mmeje — April 14, 2025.

What are hreflang tag attributes?

The hreflang attribute (also referred to as rel="alternate" hreflang="x" tells Google which language you are using on a specific page, so the search engine can serve that result to users searching in that language. 

Google introduced the hreflang attribute in December 2011 to help search engines understand the relationship between web pages in different languages.

If your website has multilingual content available in multiple languages, use hreflang tags to ensure search engines display the right language version based on user preferences.

For example, if your site has both English and Spanish versions of a page, hreflang tags tell search engines to show the appropriate version depending on the user’s language settings.

Identify and fix critical crawler issues

with Moz Pro Site Crawl

What does the hreflang attribute look like? 

Each page should reference itself and all the pages that serve as alternates. For example, a Spanish site selling Iberian ham to customers in Spain, France, and Portugal might use:

<link rel="alternate" hreflang="es-es" href="http://example.com/" />

<link rel="alternate" hreflang="fr-fr" href="http://example.com/fr/" />

<link rel="alternate" hreflang="pt-pt" href="http://example.com/pt/" />

These same hreflang annotations should appear on the French and Portuguese versions to optimize content for local preferences, including currency, shipping, and cultural differences.

Hreflang acts as a signal, not a directive. Other SEO factors, such as relevance and authority, can still influence rankings, so it’s essential to follow other international SEO best practices to reinforce hreflang’s signals.

While Google and Yandex support hreflang, Bing relies on language meta tags instead.

Benefits of using hreflang tags for international SEO

Using hreflang attributes improves international SEO by ensuring search engines serve the correct content to the right users. 

Key benefits include:

Correct language targeting: Search engines display the right page based on a user’s language settings. A French-speaking user sees the French version, while an English-speaking user sees the English version.

Avoid duplicate content issues: Hreflang clarifies which version is intended for each audience, preventing search engines from flagging similar pages as duplicates.

Improve user experience: Visitors engage more with content in their preferred language and location, leading to higher retention and conversions.

Increase search rankings: Targeting specific languages and regions makes content more relevant in search results, improving visibility and ranking potential.

Identify and fix critical crawler issues

with Moz Pro Site Crawl

How to implement hreflang tags

Using hreflang attributes correctly ensures search engines serve the right content to users based on their language and location. Follow these steps to implement them effectively: 

Adding hreflang tags to your HTML

Embed hreflang tags in the head section of your HTML to indicate language variations of a page. This method ensures the tags are always present when the page loads.

Example:

<link rel="alternate" hreflang="en-us" href="https://example.com/en-us/" />

Using sitemaps for hreflang

If modifying HTML for each page isn't practical, add hreflang annotations in your XML sitemap. This method works well for managing hreflang across many pages.

Using HTTP headers for non-HTML files

For non-HTML content like PDFs, use the HTTP header to specify hreflang tags. This helps search engines interpret language and region targeting for these files.

Where the hreflang attribute goes

Hreflang can be placed in one of the following locations:

  • On-page markup (HTML <head>)
  • HTTP headers (for non-HTML files)
  • XML sitemaps

Remember, only use one implementation method per page.

What to include in hreflang tags

When adding hreflang tags to your HTML, make sure to include the following elements:

  • rel=”alternate”: Indicates that the linked page is an alternate version of the current page.
  • hreflang=”language_code”: Specifies the language code of the linked page.
  • href=”url_of_page”: Specifies the URL of the linked page.

For example: 

<link rel="alternate" hreflang="en-us" href="https://example.com/en-us/" /> 

This code tells search engines that the linked page is an alternate version of the current page, targeted at users in the United States who speak English.

Note: Use the correct language and region codes, as specified in the ISO 639-1 and ISO 3166-1 Alpha 2 formats. This ensures that search engines correctly interpret your hreflang tags, providing the best possible user experience.

Identify and fix critical crawler issues

with Moz Pro Site Crawl

ISO language and region codes

Google supports ISO 639-1 for language codes and ISO 3166-1 Alpha 2 for region codes. These codes help search engines understand which languages and regions your content targets. Some codes may not be intuitive. For example, "gb" represents the United Kingdom instead of "uk" so always verify them before implementing hreflang. 

This hreflang tag generator can help.

Common mistakes and best practices

Incorrect codes

Using the wrong ISO code can confuse search engines and affect rankings. Double-check codes before applying them across your site.

Missing region variations 

Image from a blog post by Aleyda Solis showing how frequently the wrong hreflang attribute is used.

If a language targets multiple countries, specify regional versions. For example, instead of a generic hreflang="es", use hreflang="es-es" for Spain and hreflang="es-mx"for Mexico.

Not including a general hreflang tag 

If a language has multiple regional versions, also include a broad language tag to capture global users.

Example: Multiple hreflang tags for one language

If your page targets Amharic speakers in Ethiopia and Eritrea, use:

<link rel="alternate" hreflang="am-et" href="http://example.com" />"

<link rel="alternate" hreflang="am-er" href="http://example.com" />

To reach Amharic speakers worldwide, also add:

<link rel="alternate" hreflang="am" href="http://example.com" />

Using the correct ISO codes ensures hreflang implementation works effectively, helping search engines serve the right content to the right audience.

Identify and fix critical crawler issues

with Moz Pro Site Crawl

General targeting with x-default

Use x-default when a page doesn’t target a specific language or region. This is ideal for:

  • Language selection pages: If your website prompts users to choose a language, x-default signals that no single language version should be prioritized.
  • Global homepages: If your homepage automatically redirects users based on location or preferences, x-default helps search engines understand that it serves a broad audience.

Example: x-default implementation

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

This tells search engines that the page isn't tied to a specific language or country but instead serves as a starting point for multiple versions.

Correct hreflang implementation strengthens geotargeting and improves search accuracy, ensuring users find content in their preferred language.

The difference between hreflang and canonicalization

Both hreflang and canonical tags help search engines understand content relationships, but they serve different purposes:

  • Hreflang tells search engines which language and regional version of a page to display. It ensures users see the right content based on their location and language preferences.
  • Canonicalization identifies the primary version of duplicate or near-duplicate pages to prevent duplicate content issues.

When to use hreflang vs. canonical tags

Below are some use case explaining when to use hreflang or a canonical tag:

  • Use hreflang for pages with similar content in different languages or regions.
  • Use canonical tags for identical content across multiple URLs to consolidate ranking signals.
  • Avoid using rel="canonical" across country or language versions, as Google treats it as a directive and may ignore hreflang signals. However, canonical tags can be used within a single language version to resolve duplicate URLs.

Conclusion: Improve international SEO with hreflang tags

Use hreflang tags to ensure search engines display the right language and regional version of your content. Proper implementation prevents duplicate content issues and helps users find the most relevant page based on their location and language.

Frequently asked questions about hreflang tag

What is the use of an hreflang tag?

An hreflang tag tells search engines which language and regional version of a page to display. This ensures users see content in their preferred language and location.

What is the difference between href and hreflang?

href: Specifies the URL of a linked page.  For example:

<a href="https://example.com">Link</a>

hreflang: Specifies the language and region of a linked page for search engines. For example: <link rel="alternate" hreflang="es" href="https://example.com/es/">

Identify and fix critical crawler issues

with Moz Pro Site Crawl

Keep learning


Additional Articles on International SEO

What are ccTLDs? Why Do CCTLD Matter?