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!

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay