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)
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
In addition, To come up with a Hreflang code you must first find the country and the language code. The code supports two standards, i.e. 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
Use the HTTP Header to add Hreflang for non-HTML files like PDF documents, which lack HTML coding. This informs the search engine about the document’s language and location.
Moreover, 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.