Skip to content

Instantly share code, notes, and snippets.

@jamesmurdza
Created May 12, 2022 04:43
Show Gist options
  • Save jamesmurdza/60f35abea0be215655ce5dcd1f6b6acf to your computer and use it in GitHub Desktop.
Save jamesmurdza/60f35abea0be215655ce5dcd1f6b6acf to your computer and use it in GitHub Desktop.
Search engine friendly website localization

Search engine friendly website localization

Using code like this in the HTML head:

<link rel="alternate" hreflang="en-US” href="https://mywebsite.com" />
<link rel="alternate" hreflang="fr” href="https://mywebsite.com/fr" />
<link rel="alternate" hreflang="zh-Hans” href="https://mywebsite.com/cn" />

According to Google's SEO docs the hreflang attribute should be in one of these three possible formats:

  1. Language code. Example: zh
  2. Language and region codes. Example: zh-TW
  3. Language and script codes. Example: zh-Hant

Using codes from these three lists:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment