Hreflang
   HOME

TheInfoList



OR:

The rel="alternate" hreflang="x" link attribute is a
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
meta element Meta elements are tags used in HTML and XHTML documents to provide structured metadata about a Web page. They are part of a web page's head section. Multiple Meta elements with different attributes can be used on the same page. Meta elements can ...
described in RFC 8288. Hreflang specifies the language and optional geographic restrictions for a document. Hreflang is interpreted by
search engines A search engine is a software system designed to carry out web searches. They search the World Wide Web in a systematic way for particular information specified in a textual web search query. The search results are generally presented in a ...
and can be used by webmasters to clarify the lingual and geographical targeting of a
Website A website (also written as a web site) is a collection of web pages and related content that is identified by a common domain name and published on at least one web server. Examples of notable websites are Google Search, Google, Facebook, Amaz ...
.


Purpose

Many websites are targeted at audience with different languages and localized for different countries. This can cause a lot of
duplicate content Duplicate content is a term used in the field of search engine optimization to describe content that appears on more than one web page. The duplicate content can be substantial parts of the content within or across domains and can be either exactly ...
or near duplicate content, as well as targeting issues with users from search engines. Search engines use hreflang to understand the lingual and geographical targeting of websites and use the information to show the right URL in search results, depending on user language and region preference. There are 3 basic scenarios that can be covered with hreflang: * Same country, different languages * Different countries, different languages * Different countries, same language Hreflang attribute help your website deliver multiple variations of the website in different languages.


Implementation

Hreflang can be implemented in 3 different ways. * link element in HTML *
HTTP header The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, w ...
*
XML sitemaps The Sitemaps protocol allows a webmaster to inform search engines about URLs on a website that are available for crawling. A Sitemap is an XML file that lists the URLs for a site. It allows webmasters to include additional information about ea ...
The hreflang definition is done by creating a full set of all language and region specific versions of the same document. Every URL in the set must reference the full URL set. A self-reference is required, so the including document has to be always part of the URL set.


Language and Country Codes

Hreflang accepts values that define languages
ISO 639-1 ISO 639-1:2002, ''Codes for the representation of names of languages—Part 1: Alpha-2 code'', is the first part of the ISO 639 series of international standards for language codes. Part 1 covers the registration of two-letter codes. There are 18 ...
and countries (
ISO 3166-1 ISO 3166-1 (''Codes for the representation of names of countries and their subdivisions – Part 1: Country codes'') is a standard defining codes for the names of countries, dependent territories, and special areas of geographical interest. It ...
). A language or a combination of language and region can be used as a value. A country-only value is not allowed. Language Example
en
fr
be Language and Region Example
fr-CA
en-CA
en-US The hreflang value has to follow the standard in order to be used by search engines.


Language Script Variations

RFC 5646 allows language script variations as value for hreflang. Language script variations can directly be addressed using
ISO 15924 ISO 15924, ''Codes for the representation of names of scripts'', is an international standard defining codes for writing systems or ''scripts'' (a "set of graphic characters used for the written form of one or more languages"). Each script is given ...
. Examples
zh-Hant: Chinese (Traditional)
zh-Hans: Chinese (Simplified)


X-Default

x-default is a reserved hreflang value that can be used to specify a default version for a document. The x-default URL is not targeted at a specific region and/or language and is supposed to be shown to unspecified users. Google suggests to define an x-default version in each URL set, which will be shown to users from unspecified regions or languages in search results. Typically, in multilingual websites, the TLD (https://www.example.com) will get the x-default value in each URL set and the language folders/subdomains will be assigned hreflang values. The URL that is defined as the x-default for a certain document, can also be specified for a certain language or language and region at the same time.


Markup Examples


HTML

...


HTTP

HTTP/1.1 200 OK Content-Type: application/pdf Link: ; rel="alternate";hreflang="x-default", ; rel="alternate";hreflang="en-GB", ; rel="alternate";hreflang="en-US" ...


XML Sitemaps

http://example.com/page.html http://us.example.com/page.html http://uk.example.com/page.html ...


References

{{DEFAULTSORT:hreflang Search engine optimization HTML