Date First Published: 5th January 2023
Topic: Web Design & Development
Subtopic: SEO
Article Type: Computer Terms & Definitions
Difficulty: MediumDifficulty Level: 6/10
Learn more about what the hreflang attribute is in this article.
The hreflang attribute is used to define the country and language a page is designed to serve so that search engines can serve that result for users searching in that language, show people the right website for their country in the search results, and solve duplicate content issues.
For example, even if the French version and the UK version of a website show the same content, search engines will know that they are written for different countries. Adding the hreflang attribute will signal to search engines that a user querying in language "a" will want this result instead of a page with similar content in language "b". This attribute was introduced by Google in December 2011 to better understand the international architecture of websites.
Using the hreflang attribute has a number of benefits. It will result in each user receiving only relevant search results, improving their user experience. Optimising pages for user's locations and languages is important for improving user experience.
Hreflang attributes are signals, not directives. Even though a correct hreflang attribute will affect Google's decision on which version of a webpage is most relevant to users, adding the tag does not guarantee that search engines will show the version that you want them to show to searchers. Search engines may not use them if they consider them to be inaccurate. Hreflang is supported by Google and Yandex, but Bing does not support it. Instead, Bing uses language meta tags.
Google recommends the use of the hreflang attribute in the following situations:
The structure of the hreflang attribute is:
For example, if you have an English webpage and want to specify the Spanish version of it, you would insert the following line of code to the head of the HTML document.
The hreflang attribute can also be inserted into an XML sitemap, as shown below:
The benefits of adding the attribute to an XML sitemap are that it won't increase the file size of the HTML file with the extra markup and it is much easier to change an XML sitemap than to change all the pages on a site. However, a lot of output is required for large numbers of URLs.
Hreflang can also be used to show that there is content targeted toward variants of a single language. In that case, pages can be targeted more specifically by extending the hreflang attribute with annotations that indicate the region the content is designed for. For example, for Spain, the tag would be hreflang="es-es", and for Mexico, it will hreflang="es-mx".
No, the use of the hreflang attribute is not a direct ranking factor. Adding it will not cause it to rank higher in SERPs as that is too easy to manipulate. However, if hreflang links are missing or incorrectly implemented, search engines might consider the content of two different language versions as duplicate content, which will have a negative impact on the SEO.
If so, it is important that you tell me as soon as possible on this page.
Network Services Network Setups Network Standards Network Hardware Network Identifiers Network Software Internet Protocols Internet Organisations Data Transmission Technologies Web Development Web Design Web Advertising Web Applications Web Organisations Web Technologies Web Services SEO Threats To Systems, Data & Information Security Mechanisms & Technologies Computer Hardware Computer Software Ethics & Sustainability Legislation & User Data Protection