DEV Community

James Murdza
James Murdza

Posted on

SEO for websites with multiple languages πŸ‡¬πŸ‡§πŸ‡«πŸ‡·πŸ‡¨πŸ‡³

If your website contains content that is available in multiple languages, you may want to let Google know.

Let's say you have a page which is available in three languages: English, French and Mandarin Chinese.

You would first look up the correct language codes for those languages (see below) and then, in your page <head>, add these tags:

<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" />
Enter fullscreen mode Exit fullscreen mode

Language code formats

But how do you know the right language codes to put in the hreflang attribute? According to Google's SEO docs there are three valid formats:

  1. Language code. Example: zh is Chinese
  2. Language with a region. Example: zh-TW is Chinese as spoken in Taiwan
  3. Language and script codes. Example: zh-Hant is Traditional Chinese

The first option should do just fine for most cases!

Lists of language codes

You can quickly find the language code you're looking for on Wikipedia.

That's it!

Top comments (0)