Hreflang (Alternate) Tag

23/09/2025
Hreflang (Alternate) Tag

The hreflang (alternate) tag is an HTML attribute used to indicate local versions of pages. If pages have multiple language versions, the hreflang tag should be used to indicate to search engines that these pages have different versions.

It’s especially important for multilingual and multi-regional websites, because it helps Google (and other search engines) serve the correct version of a page based on the user’s language or location.

Purpose of Hreflang Tag Using

  • Prevents duplicate content issues across translated or localized pages. For example, if there are two pages in English, one for Canadian English and one for Australian English, without hreflang, they might be seen as duplicate pages.
    Canada: en-ca
    Australia: en-au
  • Ensures users see the right language/country version of a page.
  • Improves international SEO.

Hreflang Tag Syntax

  • rel="alternate" -> Will not change, it tells the search engine there is an alternate version
  • href="page-url" -> the URL of the alternate page
  • hreflang="xx-YY" -> language and optional region code
    • xx = ISO 639-1 language code (e.g., en, es, fr).
    • YY = ISO 3166-1 alpha-2 country code (e.g., US, GB, MX).
    • Example:
      • en-us → English (United States)
      • en-gb → English (United Kingdom)
      • es-mx → Spanish (Mexico)

Region code is optional; for example, the following just uses language codes.

Each page must include its own hreflang reference as well as references to the other language versions.

x-default: Used to indicate a fallback URL for unmatched language (e.g., a global homepage or language selector).

<link rel="alternate" href="https://juniortoexpert.com/de/namenskonvention-fur-variablen/" hreflang="de" />
<link rel="alternate" href="https://juniortoexpert.com/en/naming-convention/" hreflang="en" />
<link rel="alternate" href="https://juniortoexpert.com/es/convenio-de-denominacion-camel-case-kebab-case-snake-case/" hreflang="es" />
<link rel="alternate" href="https://juniortoexpert.com/fr/convention-de-denomination-des-variables/" hreflang="fr" />
<link rel="alternate" href="https://juniortoexpert.com/tr/degisken-isimlendirme-kurallari/" hreflang="tr" />
<link rel="alternate" href="https://juniortoexpert.com/ru/naming-convention-ru/" hreflang="ru" />
<link rel="alternate" href="https://juniortoexpert.com/en/naming-convention/" hreflang="x-default" />

Each alternate URL must be fully qualified, including the domain name, path, and transport method (http or https;)

  • https://juniortoexpert.com/en/naming-convention/True
  • //juniortoexpert.com/en/naming-convention/False
  • /en/naming-convention/False

Where to Implement Hreflang Tag?

The hreflang attribute must be placed inside the <head> section of each page, and it is only used with the <link> tag.

Note: Alternate pages must point to each other. If two pages don’t both point to each other, the tags will be ignored. 

Can Hreflang URLs Be on Different Domains or Subdomains?

Yes, if you operate separate sites for different countries or languages, you can still use the hreflang tag to tell search engines which version belongs to which audience.

Rules for Using Different Domains

Allowed setups:

  • Subdomains → en.example.com, fr.example.com
  • Subdirectories → example.com/en/, example.com/fr/
  • Completely different domains → example.com, example.fr, example.de

Reciprocal linking required:

  • Each page must reference all other alternate versions, including itself.
  • Example: If example.com points to example.fr with hreflang, then example.fr must also point back to example.com.

Consistency matters:

  • All domains should host valid, crawlable pages (no redirects, no blocked by robots.txt).
  • URLs must use the full canonical version (with correct protocol https://).

Example Across Different Domains

On https://example.com/en/:

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

On https://example.fr/fr/:

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

On https://example.de/de/:

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

Most Common FAQs About the Hreflang

Do I need to use hreflang if my site is only in one language?

No. If your site has only one language and one regional version, hreflang is not necessary. It’s only useful when you have multiple languages or country versions of the same content.

Can I use hreflang with different domains?

Yes. Hreflang works with subdirectories, subdomains, or completely different domains. The key rule is that all versions must reference each other consistently.

What’s the difference between hreflang and canonical tags?

  • Hreflang → tells search engines which version of a page to show based on language/region.
  • Canonical → tells search engines which page is the main/original version when there are duplicates. In multilingual setups, you usually need both: canonical for duplicate handling, hreflang for language targeting.

What happens if hreflang is wrong or missing?

  • If missing → Search engines might show the wrong language version.
  • If incorrect (e.g., broken links, wrong ISO codes) → Search engines may ignore the hreflang setup entirely.

Search Central Documents for Hreflang


Source:

https://developers.google.com/search/docs/specialty/international/localized-versions

0 0 votes
Post Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments