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
HTML Link Tags
<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)
| Code | Language |
|---|---|
| en | English |
| ms | Malay |
| zh | Chinese |
| ta | Tamil |
| es | Spanish |
| de | German |
| fr | French |
| ja | Japanese |
| pt | Portuguese |
| ar | Arabic |
Country Codes (ISO 3166-1)
| Code | Country |
|---|---|
| MY | Malaysia |
| SG | Singapore |
| ID | Indonesia |
| US | United States |
| GB | United Kingdom |
| AU | Australia |
| DE | Germany |
| FR | France |
Combined Examples
| Hreflang | Target |
|---|---|
| en-MY | English for Malaysia |
| ms-MY | Malay for Malaysia |
| zh-MY | Chinese for Malaysia |
| en-SG | English for Singapore |
| ms-SG | Malay for Singapore |
| en-US | English for US |
| en-GB | English for UK |
| pt-BR | Portuguese for Brazil |
| zh-CN | Chinese for China (Simplified) |
| zh-TW | Chinese 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
Subdirectories (Recommended)
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
| Error | Cause | Solution |
|---|---|---|
| Missing return links | One-directional references | Add reciprocal tags |
| Wrong codes | Invalid language/country | Use correct ISO codes (ms, not my for Malay) |
| Broken links | URLs return errors | Fix or remove URLs |
| Conflicting signals | Canonical conflicts | Align 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.