SEO

Hreflang

An hreflang tag is a HyperText Markup Language (HTML) attribute that specifies the language and geographical targeting of a webpage to help search engines display the correct regional version to users.

// definition

An hreflang attribute is an element of HyperText Markup Language (HTML) code used to specify the language and geographic audience of a webpage. It is implemented in the document header, Hypertext Transfer Protocol (HTTP) response headers, or an Extensible Markup Language (XML) sitemap using standardized language and region codes. By linking alternate versions of equivalent content, this code instructs search engine crawlers which page to display based on a visitor's location and browser settings.

Unlike canonical tags, which consolidate ranking signals by pointing search engines to a single authoritative Uniform Resource Locator (URL), hreflang attributes establish relationships between localized variants without suppressing them. While a canonical URL prevents duplicate content issues, hreflang ensures users reach the appropriate regional language variation.

// why it matters

Implementing hreflang attributes prevents multi-region websites from competing against their own localized pages in search engine results. When an organization serves customers across different countries or languages, search engines might view translated or slightly adjusted regional pages as duplicate content. Proper implementation guides search engines to deliver the relevant localized page to each visitor, improving engagement and user experience. Cross-referencing regional Uniform Resource Locators ensures search engine crawlers index every localized variation correctly, preserving overall visibility across global markets.

// example

An organization operating in Canada offers content in English and French. In the header of the English page example.com/en/, the code includes <link rel="alternate" hreflang="en-ca" href="https://example.com/en/" /> alongside <link rel="alternate" hreflang="fr-ca" href="https://example.com/fr/" />. The French page contains identical reciprocal tags. When a user in Montreal searches in French, search engines use these directives to return the French page instead of the English version.

Questions and Answers

Where do you put hreflang tags on a website?
You can place hreflang tags in the HyperText Markup Language (HTML) header section of a webpage, within Hypertext Transfer Protocol (HTTP) response headers, or inside an Extensible Markup Language (XML) sitemap. Implementing them in a sitemap is often preferred for large websites because it avoids increasing individual page file sizes.
Is hreflang the same thing as a canonical tag?
No, hreflang tags and canonical tags serve different purposes in search engine optimization. A canonical tag tells search engines which single webpage is the primary version to index, while an hreflang tag indicates that multiple pages are alternate language or regional variations intended for different target audiences.
What happens if hreflang tags are missing or broken?
If hreflang tags are missing or incorrectly configured, search engines may struggle to identify regional page variations. This can result in search engines indexing duplicate content, ranking the wrong language version in a local market, or failing to display localized pages to users, leading to poor user experiences.