Hreflang Implementation Guide

What Is Hreflang?

Hreflang is an HTML attribute introduced by Google in 2011 to help search engines understand the relationship between web pages that serve the same content in different languages or for different regions. It uses the rel="alternate" hreflang="x" syntax to declare language and optional regional targeting.

Without hreflang, search engines may treat your English and Spanish versions of the same article as duplicate content. With hreflang, they understand these are language variants — each intended for a different audience — and serve the appropriate version in local search results.

Hreflang is supported by Google and Yandex. Bing uses a different approach (the content-language meta tag and its own language markup) but does recognize hreflang to some extent.

Why Hreflang Matters for SEO

Hreflang solves three critical problems in multilingual SEO:

A study of over 10,000 multilingual websites found that proper hreflang implementation correlated with a 47% increase in international organic traffic within six months. The majority of sites without hreflang had at least one language version entirely absent from search results.

Hreflang Syntax and Language Codes

The basic hreflang syntax in HTML:

<link rel="alternate" hreflang="en" href="https://example.com/page" />
<link rel="alternate" hreflang="es" href="https://example.com/es/pagina" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/page" />
<link rel="alternate" hreflang="x-default" href="https://example.com/page" />

Language codes follow the ISO 639-1 standard (two-letter codes). Regional targeting uses ISO 3166-1 Alpha-2 country codes appended with a hyphen:

CodeMeaningUse Case
enEnglish (all regions)Single English version
en-USEnglish for United StatesUS-specific pricing, terms
en-GBEnglish for United KingdomUK-specific content
pt-BRPortuguese for BrazilBrazilian Portuguese
zh-CNChinese for ChinaSimplified Chinese

Important: You cannot use country codes alone. hreflang="US" is invalid. It must be hreflang="en-US" (language first, then optional region).

Where to Place Hreflang Tags

There are three valid methods for implementing hreflang. You should use only one method per page to avoid conflicts.

Method 1: HTML Link Elements (Most Common)

Place <link> tags in the <head> section of every language version:

<head>
  <link rel="alternate" hreflang="en" href="https://example.com/article" />
  <link rel="alternate" hreflang="es" href="https://example.com/es/articulo" />
  <link rel="alternate" hreflang="x-default" href="https://example.com/article" />
</head>

This is the simplest approach and works well for sites with fewer than 20 language versions per page. For larger implementations, the number of link tags in the head can become unwieldy.

Method 2: HTTP Headers

Useful for non-HTML content (PDFs, documents):

Link: <https://example.com/document.pdf>; rel="alternate"; hreflang="en",
      <https://example.com/es/documento.pdf>; rel="alternate"; hreflang="es"

Method 3: XML Sitemap

Best for large-scale implementations:

<url>
  <loc>https://example.com/page</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/page" />
  <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/pagina" />
</url>

This is the approach recommended by Google for sites with hundreds or thousands of translated pages. It keeps the HTML clean and centralizes hreflang management. LinguaIndex automatically generates sitemap-based hreflang for all published content.

Understanding x-default

The x-default hreflang value is a fallback — it tells search engines which page to show when no language-specific match exists for the user. Common x-default strategies:

Always include x-default. Without it, users in regions you don't specifically target may see a random language version or no result at all.

Common Hreflang Errors

Missing Return Links

The most common error. If your English page links to the Spanish version via hreflang, the Spanish page MUST link back to the English version. Google requires bidirectional confirmation. Missing return links cause Google to ignore the entire hreflang cluster.

Canonical and Hreflang Conflict

If your Spanish page has rel="canonical" pointing to the English version, you're telling Google the Spanish page is a duplicate. This directly contradicts the hreflang which says it's a language variant. The canonical wins, and your Spanish page won't rank. Each language version must have a self-referencing canonical. This is one of the main reasons translated pages don't rank.

Invalid Language Codes

Using hreflang="uk" for Ukrainian is wrong (it should be "uk" actually, but "ua" is the country code, not the language). Using three-letter codes like "eng" instead of "en" is invalid. Always use ISO 639-1 two-letter language codes.

Non-200 Status Code URLs

Hreflang URLs that return 301 redirects, 404 errors, or any non-200 status are ignored by Google. Ensure all URLs in your hreflang annotations are directly accessible and return 200 status codes.

HTTP vs HTTPS Mismatch

If your site uses HTTPS but your hreflang tags reference HTTP URLs (or vice versa), Google treats these as different URLs and the hreflang may fail. Always use consistent protocol.

Validating Your Implementation

After implementing hreflang, validate with these tools:

Run validation monthly. Hreflang errors often appear silently when new pages are added or URLs change without updating cross-references.

Hreflang and Canonical Tags

The relationship between hreflang and canonical tags is the most misunderstood aspect of multilingual SEO. Here are the rules:

Hreflang in XML Sitemaps

For sites with many translations, sitemap-based hreflang is the most maintainable approach. The XML sitemap must include the xmlns:xhtml namespace and list all language alternates for each URL:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://example.com/article</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/article" />
    <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/articulo" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/article" />
  </url>
</urlset>

Advantages of sitemap-based hreflang: centralized management, no HTML bloat, easier to automate, and easier to audit.

Managing Hreflang at Scale

When you're publishing content in 10+ languages, manual hreflang management becomes impossible. Every new translation requires updating the hreflang annotations on ALL existing language versions of that article. For a site with 1,000 articles in 15 languages, that's 15,000 pages that need synchronized hreflang tags.

Automated solutions are essential at scale. Multilingual SEO platforms handle this automatically — when a new translation is published, the system updates hreflang across all related pages, regenerates sitemaps, and submits updated URLs for re-crawling. This is the only way to maintain hreflang accuracy across thousands of pages without dedicated engineering resources.

Frequently Asked Questions

What is hreflang?

Hreflang is an HTML attribute that tells search engines which language and regional version of a page to display to users based on their language preference and location.

Where should I place hreflang tags?

Hreflang can be placed in HTML head link elements, HTTP headers, or XML sitemaps. HTML head is most common. Sitemaps are ideal for large multilingual sites.

What happens if hreflang is implemented incorrectly?

Google will simply ignore incorrect hreflang tags. It won't penalize your site, but translated pages won't get correct language targeting.

Do I need hreflang for every page?

Only pages that have translations need hreflang. If a page exists in only one language, hreflang is not necessary.

What is the x-default hreflang value?

The x-default value tells search engines which page to show when no language match exists. It typically points to your primary language version.

Automate Your Hreflang Implementation

LinguaIndex generates bidirectional hreflang tags, XML sitemap annotations, and x-default targeting automatically for every translation — zero manual configuration.