- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Hreflang: The Easy Guide for Beginners
Do you want to make sure your website is easily accessible and understood by visitors all over the world? Are you looking for a way to increase visibility and search engine optimization in other languages? Look no further than hreflang! Hreflang tags are a simple code used to tell Google that there are multiple versions of a web page - and can help your site be displayed correctly no matter where people view it from. This guide will cover everything beginners need to know about how to use hreflang on their website, so let’s get started!
What is Hreflang?
Even though they significantly increase the amount of traffic to our website, the finest SEO practices frequently fail to directly improve our ranking signals from Google.
Herflang tags are the ideal illustration of this. Google created the HTML attribute hreflang in 2011 to help address the issue of duplicate content in many languages and nations. Based on their URLs, meta tags, and content, search engines can tell which pages on your website are duplicates when they crawl them. Yet, one of the trickiest aspects of technical SEO is hreflang tags. If you use this tag property incorrectly throughout your website, you could cause much more harm than good.
Even so, once more, without hreflang, search engines might not be able to determine which version of a page to display to people based on their region and language.
For instance, if you have a page in both English and Spanish, search engines might not know which version to show to Spanish-speaking users in Spain. Hreflang allows you to specify that viewers in Spain should view the Spanish version of the page, while readers in other countries should receive the English version. But, if you use this tag property incorrectly across your website, you could cause much more harm than good.
How Does Hreflang Work?
Hreflang works by using a code to define the language and nation of a page. The code is made up of a dash, a two-letter country code, and a two-letter language code. The United States uses the code "en-us" for English, while Spain uses the code "es-es" for Spanish. The IANA website contains a comprehensive list of language and country codes.
You must include the hreflang attribute in the head section of each page of your website in order to use it. The language, country code, and URL of the page's alternate version should all be included in the attribute. For instance, if a page is available in both English and Spanish, you might add the following hreflang attributes to the head section of each page −
English Page −
<link rel="alternate" hreflang="en-us" href="http://www.example.com/page"/> <link rel="alternate" hreflang="es-mx" href="http://www.example.com/es/page"/>
Spanish Page −
<link rel="alternate" hreflang="es-es" href="http://www.example.com/page"/> <link rel="alternate" hreflang="en-us" href="http://www.example.com/en/page"/>
In the above-mentioned example, both the Mexico Spanish version and the English version of the page have alternate links on the English page. Alternate links to the English and Spanish versions of the page are provided on the Spanish page.
Search engines will see the hreflang properties when they crawl these pages and will know which version of the page to display to users based on their language and location when they do so.
Tips for Implementing Hreflang
Here are some tips for implementing hreflang on your website −
Use the Correct Language and Country Codes
It is crucial to use the appropriate language and country codes for each page when implementing hreflang. If improper codes are used, users may receive the incorrect version of the page. As was already mentioned, the IANA website contains a complete list of language and country codes.
Use the Full URL in the Hreflang Attribute
Make sure that you include the entire URL of the page's alternate version when adding the hreflang attribute to your website. Search engine issues could result in the use of a relative URL or a URL with parameters.
Test Your Hreflang Implementation
You must test your hreflang implementation before launching your website. You may test your implementation to make sure it is functioning properly using Google's hreflang testing tool.
Use Hreflang with Canonical Tags
The use of hreflang and canonical tags is vital if your website contains duplicate content. Although hreflang defines which version should be displayed to viewers based on their language and location, canonical tags notify search engines which version of a page is the preferable version.
For instance, if you have a product page that is available in both English and Spanish, you may use hreflang to specify that people in the United States should see the English version while users in Spain should see the Spanish version. The English version of the page can also be marked as the preferred version using the canonical tag.
Here's an example of how to use hreflang with a canonical tag −
English Page −
<link rel="alternate" hreflang="en-us" href="http://www.example.com/product"/> <link rel="alternate" hreflang="es-es" href="http://www.example.com/es/product"/> <link rel="canonical" href="http://www.example.com/product"/>
Spanish Page −
<link rel="alternate" hreflang="es-es" href="http://www.example.com/product"/> <link rel="alternate" hreflang="en-us" href="http://www.example.com/en/product"/> <link rel="canonical" href="http://www.example.com/es/product"/>
In the above example, the English page indicates that the English version is the preferred version and offers alternate links to the English and Spanish versions of the page. The Spanish page emphasizes that the Spanish version is the preferred version and gives alternate links for the Spanish version and the English version of the page.
Use Hreflang with Sitemaps
It can be challenging to manually add hreflang attributes to every page of a large website with numerous pages. In these situations, you can utilize sitemaps and hreflang to indicate the language and location of each page.
You must make a different sitemap for each language and national version of your website if you want to use hreflang with sitemaps. Remember, the URL and hreflang attribute of each page should be included in the sitemap.
Then, using each search engine's webmaster tools, submit each sitemap to it. By doing this, you'll be able to better inform search engines about the language and location of each page on your website.
Why Language vs. Country Targeting is Important?
When you wish to communicate with people who speak the same language in various nations, language targeting is helpful. For instance, frequent travelers or subject-matter experts who are used to reading in other languages or countries that speak the same language.
Instead, targeting users based on their nation of origin is generally more precise and efficient than targeting people based on their language.
In conclusion, hreflang can be a powerful tool for creating a comprehensive, multilingual website. However, it’s important to familiarize yourself with the proper implementation of hreflang tags and the many possibilities that you have with them before beginning your own projects. A quality implementation will make all the difference in ensuring that your website is properly indexed by search engines, as well as providing an improved experience for all of your users. With some thought, planning, and patience, you should be able to achieve successful multi-language optimization using hreflang! Happy optimizing!
Kickstart Your Career
Get certified by completing the courseGet Started