Hreflang is an HTML attribute that tells search engines about language and regional versions of a page. It helps Google serve the correct URL to users based on their language or location. Format: hreflang=“en-US” (English for US). Hreflang must be bidirectional - all versions must reference each other and themselves.

What is Hreflang?

Hreflang is an attribute that indicates the language and optionally the geographic target of a webpage. Use it when you have multiple versions of content for different languages or regions.

Hreflang purposes:

  • Show correct language version in search results
  • Prevent duplicate content issues between versions
  • Target specific geographic markets
  • Improve user experience for international visitors

When to Use Hreflang

Use Hreflang When

  • Same content in multiple languages
  • Same language, different regions (en-US vs en-GB vs en-MY)
  • Translated pages with equivalent content
  • Regional variations with different pricing/products

Don’t Need Hreflang When

  • Single language website
  • No regional targeting needed
  • Automatically translated content (consider noindex instead)
  • Different content that happens to be in different languages

Hreflang Syntax

Language Only

Use ISO 639-1 language codes.

<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="ms" href="https://example.com/ms/page/">

Language + Region

Combine language code with ISO 3166-1 Alpha-2 country code.

<link rel="alternate" hreflang="en-US" href="https://example.com/us/page/">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/page/">
<link rel="alternate" hreflang="en-MY" href="https://example.com/my/page/">

x-default

Specifies fallback for unmatched languages/regions.

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

Complete Hreflang Example

For a page with English, Spanish, and German versions:

<head>
  <!-- Self-reference -->
  <link rel="alternate" hreflang="en" href="https://example.com/page/">

  <!-- Other versions -->
  <link rel="alternate" hreflang="es" href="https://example.com/es/pagina/">
  <link rel="alternate" hreflang="de" href="https://example.com/de/seite/">

  <!-- Fallback -->
  <link rel="alternate" hreflang="x-default" href="https://example.com/page/">
</head>

Each version must include ALL hreflang tags, including self-reference.

Malaysian Bilingual Site Example

For a Malaysian site serving content in both English and Malay:

<head>
  <!-- English (Malaysia) -->
  <link rel="alternate" hreflang="en-MY" href="https://semantic.my/seo/">

  <!-- Malay (Malaysia) -->
  <link rel="alternate" hreflang="ms-MY" href="https://semantic.my/ms/seo/">

  <!-- Fallback to English -->
  <link rel="alternate" hreflang="x-default" href="https://semantic.my/seo/">
</head>

This setup tells Google to show the Malay version to users searching in Malay from Malaysia, and the English version to everyone else. Both the English and Malay pages must carry identical hreflang tags.

If the same site also targets Singapore:

<head>
  <link rel="alternate" hreflang="en-MY" href="https://semantic.my/seo/">
  <link rel="alternate" hreflang="ms-MY" href="https://semantic.my/ms/seo/">
  <link rel="alternate" hreflang="en-SG" href="https://semantic.my/sg/seo/">
  <link rel="alternate" hreflang="x-default" href="https://semantic.my/seo/">
</head>

Implementation Methods

<link rel="alternate" hreflang="en" href="https://example.com/page/">

Pros: Easy to implement, visible in source Cons: Adds to page size, must update each page

HTTP Headers

For non-HTML files (PDFs).

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

XML Sitemap

<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/"/>
  <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/seite/"/>
</url>

Pros: Centralized management, easier updates Cons: Not visible on page, may have crawl delay

For large multilingual sites with hundreds of pages, the sitemap approach is often the most maintainable.

Common Hreflang Codes

Language Codes (ISO 639-1)

CodeLanguage
enEnglish
msMalay
zhChinese
taTamil
esSpanish
deGerman
frFrench
jaJapanese
ptPortuguese
arArabic

Country Codes (ISO 3166-1)

CodeCountry
MYMalaysia
SGSingapore
IDIndonesia
USUnited States
GBUnited Kingdom
AUAustralia
DEGermany
FRFrance

Combined Examples

HreflangTarget
en-MYEnglish for Malaysia
ms-MYMalay for Malaysia
zh-MYChinese for Malaysia
en-SGEnglish for Singapore
ms-SGMalay for Singapore
en-USEnglish for US
en-GBEnglish for UK
pt-BRPortuguese for Brazil
zh-CNChinese for China (Simplified)
zh-TWChinese for Taiwan (Traditional)

Hreflang Best Practices

Bidirectional Requirement

All pages must reference each other.

Correct:

Page A (en-MY) references: A (en-MY), B (ms-MY)
Page B (ms-MY) references: A (en-MY), B (ms-MY)

Incorrect:

Page A (en-MY) references: B (ms-MY)    // Missing self-reference
Page B (ms-MY) references: A (en-MY)    // Missing self-reference

Use Absolute URLs

<!-- Correct -->
<link rel="alternate" hreflang="en" href="https://example.com/page/">

<!-- Incorrect -->
<link rel="alternate" hreflang="en" href="/page/">

Match Canonical URLs

Hreflang URLs should match canonical URLs.

<link rel="canonical" href="https://example.com/page/">
<link rel="alternate" hreflang="en" href="https://example.com/page/">

If the canonical points to a different URL than the hreflang, Google ignores the hreflang. This is one of the most common implementation mistakes.

Return 200 Status

All hreflang URLs must return 200 (not redirects or errors).

Include Self-Reference

Always include the current page in hreflang.

URL Structures for International Sites

example.com/en/
example.com/ms/
example.com/zh/

Pros: Easy to implement, shared domain authority Cons: No separate geo-targeting in Search Console

Subdomains

en.example.com
ms.example.com
zh.example.com

Pros: Can geo-target in Search Console Cons: Separate domain authority, more setup

ccTLDs

example.com.my (Malaysia)
example.co.uk (UK)
example.de (Germany)

Pros: Strong geo-signal, local trust Cons: Separate domains to manage, divided authority

For Malaysian bilingual sites, subdirectories (e.g., semantic.my/ for English and semantic.my/ms/ for Malay) are usually the simplest option. You keep one domain’s authority and manage hreflang through a single sitemap.

Troubleshooting Hreflang

Common Errors

ErrorCauseSolution
Missing return linksOne-directional referencesAdd reciprocal tags
Wrong codesInvalid language/countryUse correct ISO codes (ms, not my for Malay)
Broken linksURLs return errorsFix or remove URLs
Conflicting signalsCanonical conflictsAlign canonical and hreflang

Validation Tools

  • Google Search Console - International Targeting report, Coverage report for hreflang errors
  • Ahrefs Site Audit - Hreflang tag validation across all pages
  • Semrush Site Audit - Detects missing return tags and invalid codes
  • Screaming Frog - Crawls and maps all hreflang relationships

Search Console Reports

Check:

  • International Targeting section
  • Coverage report for hreflang errors
  • URL Inspection for specific pages

Run a crawl with Screaming Frog or Ahrefs Site Audit after any hreflang changes. Broken return links are the most frequent error and they silently invalidate your tags.

Hreflang Checklist

Implementation

  • All language versions identified
  • Correct ISO codes used (ms for Malay, not my)
  • x-default included
  • Absolute URLs used
  • Self-reference on each page

Validation

  • Bidirectional links verified
  • All URLs return 200
  • Canonical URLs match hreflang URLs
  • No conflicting signals
  • Google Search Console checked

Maintenance

  • New pages get hreflang tags
  • Removed pages cleaned up
  • URL changes updated
  • Regular audits scheduled (Ahrefs/Semrush monthly)

Hreflang ensures users see the correct language version in search results and prevents duplicate content issues between regional versions. For Malaysian bilingual sites, proper en-MY and ms-MY tagging is the difference between reaching both language audiences and leaving one underserved.

Implement hreflang on all alternate versions, always include self-reference, and ensure bidirectional linking. Use x-default as a fallback for unmatched languages. Validate regularly with Google Search Console and crawl tools like Screaming Frog or Ahrefs.

Combine hreflang with proper canonicalization and a clear URL structure for effective multilingual search visibility. Hreflang is a key part of technical SEO for any site serving multiple language audiences, and it pairs well with a solid international SEO strategy.

Frequently Asked Questions

Do I need hreflang for different English versions (US, UK, AU)?
Yes, if you have distinct content for different English-speaking regions (different spellings, pricing, products), use hreflang with region codes: en-US, en-GB, en-AU. If the content is identical, you may not need separate versions. Hreflang helps prevent duplicate content issues between regional versions.
What is x-default in hreflang?
x-default specifies the default or fallback page when no other hreflang matches the user's language/region. It's typically your main language version or a language selector page. Always include x-default to handle users whose language isn't specifically targeted.
Does hreflang affect rankings?
Hreflang doesn't directly boost rankings, but it helps the correct page rank in the correct market. Without hreflang, the wrong language version might rank in a market, or versions might compete against each other. Proper implementation ensures the right page appears for the right audience.
How do I set up hreflang for a Malaysian bilingual site (English and Malay)?
Use en-MY for English content targeting Malaysia and ms-MY for Malay content. Each page needs both hreflang tags plus x-default. For example: hreflang='en-MY' for semantic.my/page/ and hreflang='ms-MY' for semantic.my/ms/page/. Set x-default to your primary language version. Validate with Google Search Console's International Targeting report.