What is Hreflang
Hreflang is an HTML attribute used to serve pages based on specific countries and languages. This attribute plays a major role in International SEO. The structure looks like this.
<link rel=”alternate” href=”url_of_page” hreflang=”lang_code” />
Example
<link rel=”alternate” href=”https://example.com/es/” hreflang=”es” />
The two-letter code stands for language while the country is in written capital MX (MX stands for Mexico)
The syntax means
link rel=”alternate” means the link in this tag is an alternate version of this page
href=”url_of_page” is where you can find the alternate page
hreflang=”lang_code” is what the alternate language is
To come up with a Hreflang code you must first find the country and the language code. The code supports two standards they are two letter syntaxes ISO 639-1 language codes and ISO 3166-1 alpha-2 country codes. These options are supported by Google.
Examples of Language Codes
en
fr
be
Examples of Language and Region Codes
fr-CA
en-CA
en-US
The other methods to indicate multiple versions of the page are
HTTP Headers
Sitemap
Adding Hreflang is used for non-HTML files like PDF documents which do not have HTML coding. Thus HTTP Header is used to inform the search engine about the language and location of the document.
Adding Hreflang to XML SiteMap tells the search engine where to find the different version of the page that carries a different language. The three methods are acceptable from Google’s perspective and you can choose the one you prefer.