Skip to content
Meirra
Skip to main content

Hreflang Implementation Guide

Hreflang Implementation Guide

The complete technical guide for multilingual websites targeting Spanish & English markets

Updated: 2025-04-15
25 min read
Technical Guide
MeirraMeirra is loading

Meirra

SEO & Web Development Expert, Meirra

Understanding Hreflang

Hreflang Guide

Understand and optimize your hreflang tags for international SEO

Understanding Hreflang

The hreflang attribute tells search engines which language you're using on a specific page, so they can show the right version to users searching in that language.

Introduced by Google in 2011, hreflang is now a critical component of international SEO, helping avoid duplicate content issues and ensuring users see content in their preferred language.

The attribute uses ISO language codes (like 'en' for English or 'es' for Spanish) and optional regional subtags (like 'es-ES' for Spanish in Spain or 'es-MX' for Spanish in Mexico).

This comprehensive guide covers everything you need to properly implement hreflang tags for websites targeting both Spanish and English markets. Hreflang implementation is one of the most technically challenging aspects of multilingual SEO, but when done correctly, it ensures search engines serve the right language version to the right users.

We'll walk through multiple implementation methods, provide tested code examples, offer specific guidance for Spanish market targeting, and help you troubleshoot common errors.

Basic Example

Basic Hreflang Implementation

Note how each page must have the complete set of hreflang tags

HTML
<head>
  <!-- Other meta tags, title, etc. -->
  
  <!-- English page (example.com/page) would have these tags: -->
  <link rel="alternate" hreflang="en" href="https://example.com/page/" />
  <link rel="alternate" hreflang="es" href="https://example.com/es/page/" />
  <link rel="alternate" hreflang="x-default" href="https://example.com/page/" />
  
  <!-- Spanish page (example.com/es/page) would have these same tags: -->
  <link rel="alternate" hreflang="en" href="https://example.com/page/" />
  <link rel="alternate" hreflang="es" href="https://example.com/es/page/" />
  <link rel="alternate" hreflang="x-default" href="https://example.com/page/" />
</head>

Why It Matters

  • Prevents duplicate content issues across language versions
  • Ensures search engines serve the correct language to users
  • Helps maintain separate index rankings for each language version
  • Improves user experience by showing content in users' preferred language
  • Critical for businesses targeting both Spanish and English markets

Common Mistakes

  • ✕
    Missing return links (not creating bidirectional references)
  • ✕
    Incorrect language or country codes
  • ✕
    Mixing relative and absolute URLs
  • ✕
    Conflicting canonical and hreflang signals
  • ✕
    Improper nesting in XML sitemaps
  • ✕
    Self-reference tags missing

Hreflang Language Codes

Explore valid language codes to use in your hreflang tags.

en

Common

English

en-US

Common

English (United States)

en
+
US

en-GB

Common

English (United Kingdom)

en
+
GB

en-CA

Common

English (Canada)

en
+
CA

en-AU

Common

English (Australia)

en
+
AU

es

Common

Spanish

es-ES

Common

Spanish (Spain)

es
+
ES

es-MX

Common

Spanish (Mexico)

es
+
MX

es-CO

Common

Spanish (Colombia)

es
+
CO

es-AR

Common

Spanish (Argentina)

es
+
AR

fr

Common

French

fr-FR

Common

French (France)

fr
+
FR

fr-CA

Common

French (Canada)

fr
+
CA

de

Common

German

de-DE

Common

German (Germany)

de
+
DE

it

Common

Italian

it-IT

Common

Italian (Italy)

it
+
IT

pt

Common

Portuguese

pt-BR

Common

Portuguese (Brazil)

pt
+
BR

pt-PT

Common

Portuguese (Portugal)

pt
+
PT

zh

Common

Chinese

zh-CN

Common

Chinese (China)

zh
+
CN

zh-TW

Common

Chinese (Taiwan)

zh
+
TW

ja

Common

Japanese

ja-JP

Common

Japanese (Japan)

ja
+
JP

ko

Common

Korean

ko-KR

Common

Korean (South Korea)

ko
+
KR

ru

Common

Russian

ru-RU

Common

Russian (Russia)

ru
+
RU

ar

Common

Arabic

nl

Common

Dutch

nl-NL

Common

Dutch (Netherlands)

nl
+
NL

x-default

Common

Default

x
+
default

Code Format

Hreflang language codes follow ISO 639-1 format for languages (two letters, e.g., "es") and optionally ISO 3166-1 Alpha-2 for countries (two letters, e.g., "ES"). Always use lowercase for the language code and uppercase for the country code.

Hreflang Code Generator

Implementation Methods

CMS Implementation

Testing & Validation