A Guide to Hreflang Tags for International SEO

0:00 / –:–

Hreflang focuses on the right user with the corresponding language and region. We explain the use of syntax, the role of x-default, and the difference between sitemaps and tags, and how the canonicals work with hreflang.

A hreflang tag is a code snippet that tells search engines like Google which language and regional version of a page to show to a user. While it can be a complex part of international SEO, it is essential for improving user experience and avoiding issues with duplicate content.

Structure of an Hreflang Tag

Diagram that illustrates the proper construction of an hreflang element with designated language and country codes.

Elements and Placement

An hreflang tag is a <link> element placed in the <head> section of a webpage. Therefore, its structure should include three key components.

  • link rel=”alternate”: This attribute signals to search engines that an alternate version of the page exists.
  • hreflang=”lang-code”: This attribute specifies the language, and optionally the region, for which the alternate page is intended.
  • href=”url of page”: This attribute contains the full URL of the alternate page.

Hreflang Code and x-default Value

The value used for the hreflang attribute must follow specific formats for language and region codes. In short, stick to the standards to avoid errors.

  • Language Code: A required two-letter code (ISO 639-1) identifies the language (e.g., en for English, es for Spanish).
  • Region Code: An optional two-letter code (ISO 3166-1 Alpha-2) can be added to target a specific region (e.g., es-mx for Spanish in Mexico, en-gb for English in Great Britain).
  • x-default: A special value, hreflang="x-default", specifies a fallback page for users whose language and region settings do not match any other hreflang tag. Consequently, it is often used for a homepage with a country selector or a primary global site.

Common ISO Language and Region Codes

LanguageISO 639-1 CodeCountryISO 3166-1 Alpha-2 Code
EnglishenUnited StatesUS
SpanishesUnited KingdomGB
GermandeCanadaCA
FrenchfrAustraliaAU
Chinese (Simplified)zhMexicoMX
JapanesejaSpainES
PortugueseptGermanyDE
ItalianitFranceFR
RussianruBrazilBR
ArabicarChinaCN

How to Set Up Hreflang Tags

Table outlining the advantages and disadvantages of using hreflang tag HTML integration, HTTP Header, and Sitemap.

Implementation Methods Overview

There are three primary methods for implementing hreflang tags. Therefore, choose the one that fits your stack and team.

MethodHow It WorksProsConsBest For
HTML<head> Tags<link> elements are added to the <head> of every page in a group.Easy to understand; visible in page source for checking.Adds code to HTML; hard to maintain on large sites.Small to medium websites with few language versions.
XML SitemapEach page has one entry with <xhtml:link> elements for all language versions.All hreflang in one file; easier updates without HTML changes.Initial setup needs a developer; must keep file updated.Large sites with many languages and consistent template pages.
HTTP HeaderThe server sends a Link HTTP header with hreflang info.No change to HTML; may save space on pages.Not all servers support it; harder to audit.Advanced sites with performance-focus and control over headers.

Big Hreflang Rules and Common Mistakes

Illustrates frequent problems faced with hreflang including faulty codes and missing return tag issues.

A single mistake can cause hreflang implementations to fail, so it is crucial to follow the rules strictly. As a result, review these points before launch.

Key Rules

  • Return Tags (Reciprocity): If page A links to page B as an alternate version, page B must link back to page A. Search engines may ignore the tags if this two-way link is not present.
  • Self-Referencing Tags: Every page within a hreflang set must include a tag that points back to its own URL.
  • Self-Pointing Canonicals: Each page in a hreflang group should have a rel="canonical" tag that points to itself. Pointing all canonical tags to a single “main” version will cause search engines to ignore the hreflang tags and only index the canonical URL.

Common Errors to Avoid

  • Using incorrect language or region codes, such as en-UK instead of en-GB.
  • Pointing hreflang tags to pages that are broken, redirecting, or blocked by robots.txt.
  • Using relative URLs (e.g., /page.html) instead of absolute URLs (e.g., https://example.com/page.html) in the href attribute.
  • Linking to non-equivalent content, such as linking a product page in one language to the homepage in another.

How to Audit and Debug Hreflang

A flow chart that demonstrates the auditing process and shortcomings of added hreflang tags.

Regular audits are important for catching errors, especially on large websites. However, the hreflang report in Google Search Console was deprecated, so third-party tools can help identify issues.

Using Third-Party Tools

Tools like Screaming Frog and Ahrefs can crawl a site and report on hreflang issues. For example, both can be configured to check for common problems, including the following.

  • Missing return links or reciprocal tags.
  • Missing self-referencing hreflang tags.
  • Incorrect language and region codes.
  • Broken URLs in hreflang attributes.
  • Conflicts between hreflang and canonical tags.

Manual Checks

For quick checks on important pages, view the page source and inspect the <head> section. Next, verify that a self-referencing tag exists, the codes are correct, and that alternate versions link back to the original page. Finally, confirm that the rel="canonical" tag on each page points to itself.

Implementation steps

  1. List all language and region URL versions along with their canonical tags.
  2. Drop hreflang tags (or XML entries) for each region, and loop back each page to itself.
  3. If there’s a catch-all lang switch, mark a single x-default URL.
  4. Every translated page must self‑canonical—don’t cross-link canonicals between languages.
  5. Double-check reciprocity with a tool, then log hreflang issues in GSC reports

Frequently Asked Questions

What does hreflang do?

It connects different language or region versions, so users land on the right local page.

Where can I implement it?

Place it in the HTML head or in XML sitemaps, and make sure tags point back to one another.

What is x-default?

A back-up URL for users whose language or region isn’t specified—think of it as a location chooser.

How do canonicals interact?

Keep each language page self-referential with canonicals—don’t point them all to one single canonical.

Common mistakes?

Wrong codes, no return tags, or all variants pointing at one single URL.

0
Show Comments (0) Hide Comments (0)
Leave a comment

Your email address will not be published. Required fields are marked *