What Is Hreflang Attribute?

The hreflang attribute is a meta tag that can be added to the head of an HTML document in order to indicate language targeting. This attribute helps users identify more easily which version of your website or blog post they are viewing, as well as what country it’s being viewed from. It also lets search engines know whether you support multi-language content on your site so that they can provide relevant results for visitors accordingly.

Hreflang is a Google Search Console feature that allows you to specify the language of your website. It is important for search engine optimization and international SEO.

What is the Hreflang Attribute and how does it work?

Hreflang is an HTML link> or link> tag element that informs search engines about the connection between pages on your website that are written in various languages. Based on the searcher’s country and language choices, Google utilizes the attribute to deliver the appropriate regional or language URLs in its search results. 

For those concerned with the SEO of an international website, Hreflang is a must-know attribute.

What Is The Purpose Of An Hreflang Tag?

The tag may be used in one of three ways, according to Google support (you only need to choose one). 

  1. as a link in the page’s HTML head

  2. The HTTP headers (for non-HTML files like PDFs)

  3. On the sitemap in XML

  1. As a hyperlink in the page’s head>

The hreflang property has the following format:

hreflang=”(language and country code)” rel=”alternate” href=”(URL)” hreflang=”(language and country code)”

  • Similar to the rel=”canonical” tag, rel=”alternate” alerts search engines that there is alternative version of this page. 

  • href= – The URL after href= is the address of the requested page. 

  • hreflang=– – – – – – – – – The hreflang property provides the alternative page’s nation and language. Use language and country codes to choose which website should be shown. 

When writing language codes in the tag, they must use the ISO 639-1 two-letter code format. For instance, en (English), es (Spanish), and zh (Chinese) are all examples of languages (Chinese). 

A country code is not required if you are merely translating a website inside the same nation. However, if you use a country code, it must be in ISO 3166-1 Alpha 2 format, such as au (Australia), us (United States), or sg (Singapore) (Singapore).

Always put the language code first, followed by the nation code, when creating the hreflang tag. For instance, en-au, es-us, and zh-sg

For example, if the webmaster of example.com wishes to display her homepage to English- and Spanish-speaking readers in the United States, she might include the following annotations in the HTML’s head> section:

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

/> link rel=”alternate” href=”https://www.example.com/es” hreflang=”es-us” /> link rel=”alternate” href=”https://www.example.com/es” hreflang=”es-us” />

The hreflang annotation might look like this if she wanted to expose the webpage to Spanish-speaking readers in Venezuela and Mexico:

/> link rel=”alternate” href=”https://www.example.com/ve” hreflang=”es-ve” /> link rel=”alternate” href=”https://www.example.com/ve” hreflang=”es-ve” />

/> link rel=”alternate” href=”https://www.example.com/mx” hreflang=”es-mx” /> link rel=”alternate” href=”https://www.example.com/mx” hreflang=”es-mx” />

The hreflang tags generator from aleydasolis.com was used to create these tags. If you want an additional help getting this correctly, try it yourself.

Keep in mind that the head> and header> parts are not interchangeable. Information that should not be shown on the page should be placed in the head> section. This is where your hreflang attribute should go. A header> element informs a bot or screen reader that the information it wraps around should be regarded the page’s or section’s introduction.


For PDFs and non-HTML material on your website, HTTP headers should be utilized to support hreflang. This has nothing to do with the on-page head> or header> HTML elements, and is instead configured in the site’s backend.

The issue with utilizing HTTP headers, according to Yoast, is that it might add a lot of overhead to each request performed on your site, thus slowing down the user’s browsing experience. 

Nonetheless, to identify a PDF document on your site that is available in both English and French, the link should appear in the HTTP header as follows:

Link: http://en.example.com/document.pdf>; rel=”alternate”; hreflang=”en”, http://fr.example.com/document.pdf>; rel=”alternate”; hreflang=”en”, http://fr.example.com/document.pdf>; rel=”alternate”; hreflang=”en”, http://fr.example.com/document.pdf> ; hreflang=”fr”; rel=”alternate”

  1. On the Sitemap XML

The sitemap.xml is the third recommended method for integrating hreflang on a website. A wonderful Google support post with thorough instructions may be found here.

Highlights: Other Hreflang Topics We’ll Discuss

  • Troubleshooting And Common Errors

  • Some Things to Consider Before Using Hreflangs

  • Why Should Hreflang Attributes Be Used?

  • Hreflang isn’t used for a variety of reasons.

Troubleshooting And Common Errors

For a long time, Aleyda Solis’ Search Engine Land blog on auditing hreflang problems has been a go-to reference for many to get things right, particularly when working with many languages and locations.

Underscores And Typos

Simple errors in the language or country code are relatively typical blunders on foreign websites attempting to apply hreflang, according to both of the aforementioned publications.

Simple mistakes like providing an incorrect country code, omitting the language code, or using an underscore (_) instead of a hyphen (-) might make your hreflang property invalid. Although, according to a 2017 Twitter discussion between Google Webmaster Trends Analyst Gary Illyes, doing it incorrect should not give Google too much difficulty — at least in principle.

I know it doesn’t, but you requested a preferred version, and you received one.

May 24, 2017 — Gary/Illyes (@methode)

Although there is some wiggle area for using GB and UK as country codes (since Google is fairly savvy), you should always use the ISO 639-1 standard to display language. If you use the wrong abbreviation (for example, eng instead of en), Google will most likely disregard you, and your code will not function.

Self-Referencing Hreflangs aren’t used.

Another typical mistake is not include a self-referential hreflang tag on the page. This necessitates the use of a hreflang tag that refers the page’s language and country as well as identifying the other sites.

Ignoring Bing

Finally, if you want your foreign website to run on Bing, you’ll need to follow their specific instructions. There is a Bing Webmasters page that will show you how to notify Bing what language and country code your website is in, however it looks to be out of date, since the http-equiv=”content-language” meta tag it offers is considered poor practice since HTML5.

Instead, the conventional thinking is to use lang= to identify a page’s language and a Content-Language header to indicate the target audience.

Examine Your Hreflang Problems

With SEMrush’s Site Audit Tool, you can check the health of your website.

ADS illustration

Some Things to Consider Before Using Hreflangs

You’re at risk of being ignored by Google.

At least according to Google, hreflang annotations are treated as signals rather than instructions. In other words, they may be overlooked by Google. It should work, but there’s no way to know for sure.

Consider a language code that does not include a country code.

There are additional methods for a user to be sent in the incorrect path. 

If you only provide a URL for speakers of a language who live in the countries you specify (e.g., en-us), but don’t specify a URL for a user of that language who lives in a country for which you haven’t supplied a code (e.g., an English speaker in Italy), Google will make the best estimate. 

That is to say, it is possible that it will make a mistake. 

Consider introducing a generic tag with no country code but a language code. This generic hreflang=”en” tag, for example, might be used to specify which version of a website should be delivered to an English-speaking user in Italy.

When it comes to implementing hreflang tags, there are a number of additional considerations. This video from Google is a few years old, but it gives you a fair idea of what may go wrong. It’s well worth your time to watch.


You don’t want to be targeted? Use the x-default option.

When you use hreflang=”x-default,” you’re basically stating, “This URL doesn’t target any language — it’s available to everyone.” It’s ideal for pages that cater to a variety of languages or are language selection pages. It’s obviously preferable than providing tags for a large number of languages.

Using Hreflang vs. Not Using Hreflang

Implementing Hreflang can help with a variety of regional and linguistic challenges. However, this does not necessarily imply that it is the best option for you.

Why Should Hreflang Attributes Be Used?

Benefit of SEO: Eliminating Duplicate Content Issues

The most significant benefit of employing hreflang is the ability to rapidly and efficiently resolve true duplicate concerns. Large chunks of a site spread among numerous regional domains, subdomains, or subfolders aimed at various nations might be regarded as virtually or completely similar.

Consider a company that sells the same 100 products in the United States, Canada, the United Kingdom, Ireland, and Australia, but each has its own URL. 

That firm then has a dilemma: should it develop individual product descriptions, blogs, guidelines, and category pages for each market in order to minimize any negative effects on search performance caused by duplicate content? Or does it merely use hreflang tags to save countless hours of work?

User Advantage: Better-Targeted Content

Perhaps you’ve gone to the trouble of using British terminology and spelling across your site’s UK edition. You’ve even included a few pop culture allusions that the ordinary US site visitor might miss. Hreflang tags may help users from the United States and the United Kingdom feel more at ease.

Hreflang isn’t used for a variety of reasons.

You’ve got duplicate content in many languages.

Hreflang properties aren’t essential to prevent duplicate content concerns on sites that are straight translations of one another, although they’re nice to have. 

Although Google still encourages utilizing hreflangs to aid its crawlers, numerous versions of a page will not be considered duplicates as long as the majority of the content is translated. 

So, don’t anticipate a lot of hreflang implantation to rescue you from any negative effects on rankings since, in this case, you probably don’t need to worry about it.

You want to prevent people from other countries from searching on Google.

If you want to be quite confident that only viewers from a particular nation will see your site in Google’s results, hreflang may not be the ideal solution. Instead, if you have a general top-level domain, such as.com, rather than something like.ca, Google Search Console may give a more failsafe, if less forgiving, solution.

Choose a target country and click the ‘Geographic target’ option in Google Search Console’s International Targeting report’s Country tab.

This may seem to be a good idea. In fact, if you’re certain you don’t want any organic search traffic from outside a particular nation, it could be a good idea. However, keep in mind that Google will strive to prevent your site from being shown to anybody in another nation, rather than merely better targeting searchers in your desired location. 

Are you positive that no one in another country, even a citizen on the other side of the globe, would find your service or goods valuable and become a possible consumer or client?

Perhaps you’d want to take the polar opposite approach. Select ‘Unlisted’ in the dropdown box connected with the ‘Geographic target’ checkbox to perform the opposite of the above. As a result, your website will be free of geographical restrictions.

You’re just concerned about optimizing for Bing or Baidu.

Yes, most Western websites seem to be immune to this, but it is conceivable. It is even legal in certain parts of the globe.

As previously stated, Bing does not employ hreflang tags to determine a page’s preferred language and country. Neither does Baidu, China’s most popular search engine. 

If reaching a Chinese audience or maximizing Bing traffic is important to you, you should declare language and targeted audience on an HTTP header level. 


Hreflang is a link> tag property that aids search engines in serving foreign web visitors the relevant version of a website. Everywhere you utilize the attribute on your website, it’ll be critical to use the right language code and country code. 

Check out the SEMrush Site Examine tool if you wish to audit your website’s usage of the hreflang tag for any issues. There are several foreign SEO tests built in, so you can start optimizing your worldwide website right now!

Get a 7-day trial for free.

Begin to improve your web exposure.

ADS illustration

Hreflang is a technique in which multiple versions of the same website are created for different languages. Hreflang attributes are used to specify the language and country of the content on your website. Reference: hreflang html.

Frequently Asked Questions

What is the use of hreflang attribute?

A: The text-based markup language that identifies a documents target language or geographic region.

What is hreflang?

A: Hreflang is a code that indicates the language of your page. Its used when youre doing international SEO to tell search engines which version of your webpage to show in different countries, so they can rank the right country for visitors looking in their native language.

Should I use hreflang?


Related Tags

  • hreflang spanish
  • hreflang generator
  • hreflang language codes
  • hreflang checker
  • hreflang tags

Leave a Comment

Your email address will not be published.