Dj Techblog

A blog on web development

Hreflang to optimize website for various language audiences

Last modified on March 6, 2021
Hreflang to optimize website for various language audiences

If you have a website which you want to optimize for the search engines so that it shows up to users across various geographical location. Or, in simple words if you are writing content which are helpful for visitors of different countries having different default language. You can use a specific html tag that is hreflang. The hreflang helps you set the language of the article and the coutry in which you want your article to rank. In this article I will show you how to use alternate hreflang tag.

These techniques are generally known as International seo which you can use to target a larger base of audience.

How to target international audience with hreflang?

Well, targeting audience of different languages might look easy, but it is not. We can not just write the content in more than one language and publish it. Because if we just the copy the web content in more than one language and specify a different url for each of the version. Search engine will see that same content is span across multiple urls. So, you are just confusing the search engine bots to which version of the content to index and which one to ignore. Because search engines are not going to index the urls if they found duplicate contents in all the urls.

In such scenario search engine bots will index one arbitrary url and ignore others. The url which was indexed by the search engine bots may be the different from the one which you wanted to be.

So, when you write article in more than one languages keep two important points in mind.

1. Set one url as canonical.
2. Rest urls will be treated as alternate.

Specification of hreflang

<link rel="alternate" hreflang="language-country-code" href="absolute url of the web content"
The rel="alternate" filed specifies that the url which was presented here is the alternative of the original documnet and do not index this url.

How to use hreflang in your website

Consider you have written an article in four different language, say article-hi.html, article-en.html, article-fr.html, article-ru.html. You want to rank each of the article in their respective geographical region with hreflang tag. But wants to index only one article say article-en.html.

Write the below code in the all the four pages.

<link rel="canonical" href="article-en.html" />
<link rel="alternate" hreflang="hi-in" href="article-hi.html" />
<link rel="alternate" hreflang="fr-fr" href="article1-fr.html" />
<link rel="alternate" hreflang="ru-ru" href="article1-ru.html" />

This way, you can set your article to rank in different geographical location using different language and country code.

However, you can also use a language with more than one country code like below. The article-en.html has been used for USA, but it can also be used for other english speaking countries like en-ca for Canada, en-ie for Ireland, en-au for Australia, en-gb for United Kingdom and so on. Similarly the article-hi.html can also be used for neighbouring countries like Pakistan, Bangladesh, Srilanka etc.

Points to remember while implementing hreflang tag

1. Always state the absolute url of the webpage in the href=" " field. Relative url of the document wont work and can create problems.
2. All the hreflang tags should point to itself and other hreflang too if any. 3. Do not forget to choose the canonical version of the duplicate content. You must have a page which point to itself as canonical. All other duplicate pages should also mention what is their canonical version. If not mentioned Google might confuse about the original version of the duplicate contents.

Alternate ways to set language of a page

1. HTTP headers
You can return an HTTP header with your page's GET response to tell Google about all of the language and region variants of a page. This is useful for non-HTML files (like PDFs).

2. You can use a Sitemap to tell Google all of the language and region variants for each URL. To do so, add a <loc> element specifying a single URL, with child <xhtml:link> entries listing every language/locale variant of the page including itself. Therefore if you have 3 versions of a page, your sitemap will have 3 entries, each with 3 identical child entries.

See details here, Official documentation of Google.

If you like this article, share with your friends. It will inspire me to write more.

Published on March 6, 2021


Intro

Debabratta Jena

I mainly write about HTML5, CSS3, Javascript, Angular JS, Ajax, PHP, Mysql, On page SEO, Google Ads, Tag manager, Universal Analytics, Google My Business, SERP, Apache server configuration etc, Yoga is my passion.

Reach to me in the contact us form below

Follow me on

Contact us

Subscribe

Tags

Php HTML5 Javascript CSS Ajax Angular JS Google My bisiness Listing Google tag Manager Google Universal Analytics Search Engine Optimization On page SEO Off page SEO Google Marketing platform Digital Marketing Google Ads Mysql Apache Server

×

Subscribe to get email notification about our new post

Name

Email

We neither sell nor share your personal information with any third party. Your identity is safe with us.