How To Add Lang And Hreflang Attributes To The Page Code
What are lang and hreflang attributes?
Besides, these attributes help to avoid problems with Content Duplication, which may be a reason for pages indexing with similar content for a variety of regions.
For example, in the international on-line shop there will be the same descriptions of goods, however, the currency will differ for Great Britain and the USA. If you do not indicate the separate region for every page version, search systems can consider them duplicates.
Google recommends pointing out language and regional versions for multilingual sites for the following cases:
- by means of hreflang attribute HTML tag <link>:
- by adding versions in HTTP headers:
- in the sitemap.xml file:
- by adding <lang> attribute in the <html> tag:
Rules for specifying languages and pages regions
- Tags will be considered by search systems if all language pages have reciprocal links. At the same time, every page variation must have his own hyperlink;
- it is necessary to indicate complete addresses, starting with HTTP or HTTPS;
- page versions can be hosted on different domains;
- hreflang attribute may contain the information only about language code or completed with region data, for which a specific page is created;
- it is expected, what version will be displayed for the user, whose browser settings has language different from the presented resource. For example, a user who speaks Chinese is more likely to understand the page in English than in Ukrainian.
- if the project has IP-dependent pages, from which users are served to the appropriate language version of the site;
- for pages, having the possibility of dynamic content choice on some languages;
- for pages where there are a language and region selections.
How to use hreflang in <link> tag
Google cannot recognize an appropriate language for the visitor based on the URL; it is important to indicate its code explicitly. In this case, users from Russia, Ukraine, and England or visitors, speaking of these languages, reach necessary landing pages from search results. The information about the region and language of the user is defined by browser settings.
This way can be rather cumbersome for sites, which are translated into many languages. Adding a long code with all links negatively affects the performance of the project. Therefore, for such major projects, it may be preferable to use other ways of indicating the languages.
Using hreflang in HTTP headers
The information in headers is written in the following way:
Adding hreflang to Sitemap
Using lang attribute in <html> tag
The example of syntax to set English language:
Validation of multilingual project version
|Create a project|
Learn how to get the most out of Serpstat
Want to get a personal demo, trial period or bunch of successful use cases?
Send a request and our expert will contact you ;)
Cases, lifehacks, researches and useful articles
Don’t you have time to follow the news? No worries!
Our editor Stacy will choose articles that will definitely help you with your work. Join our cozy community :)