What Is a Hreflang Tag? (Complete Explanation for SEO)
A hreflang tag is an HTML link element attribute that tells Google and other search engines which language and geographic region a specific page is intended for. It is placed in the <head> section of a page as a <link rel="alternate" hreflang="language-region" href="URL"> element.
Hreflang Tag Syntax and Format
The correct hreflang tag syntax uses BCP-47 language codes. The language portion is a two or three letter ISO 639-1 code (e.g. en, fr, de, zh). The optional region portion is a two-letter ISO 3166-1 Alpha-2 country code (e.g. GB, US, IN). They are joined with a hyphen.
<!-- English for all regions -->
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<!-- English for United Kingdom -->
<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/" />
<!-- French for France -->
<link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/" />
<!-- Fallback for all others -->
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
Where Can Hreflang Tags Be Placed?
Google supports hreflang implementation in three locations: in the HTML head as link elements (most common), in the HTTP header as Link response headers (useful for PDFs and non-HTML files), and in an XML sitemap using the xhtml:link attribute inside each <url> block. All three methods are equally valid. Our hreflang validator checks the HTML head implementation.
What Is the Difference Between Hreflang and Canonical?
A canonical tag tells Google which URL is the preferred version when duplicate or near-duplicate content exists. A hreflang tag tells Google which language and regional version of a page to serve to which users. They serve different purposes and are often used together on multilingual sites. A page can have both a canonical tag and hreflang tags simultaneously without conflict, as long as the canonical on each alternate page points to itself and not to the primary language version.