Skip to content
跨境独立站开店
Guides

What is an hreflang tag? How to create a sitemap for a multilingual website.

This article explains the meaning and role of the hreflang tag. Learn how to set it up on multilingual websites, key points and considerations for sitemap creation, and use this information to your advantage in cross-border e-commerce.

Check Shopify registration offers in your regionSee current offer

This article explains the meaning of the hreflang tag, its benefits, and how to set it up.

For businesses operating globally, it's crucial not only to make e-commerce sites multilingual but also to configure them so that the most relevant page is displayed to each user. This is where hreflang tags come in. By properly configuring hreflang tags, search engines can correctly recognize the target language and region of each page, making it easier to display the most appropriate page for the user.

This article introduces the overview and benefits of the hreflang tag. Learn about the points to note when setting it up and how to verify its implementation to help you with cross-border e-commerce.

What is an hreflang tag?

The hreflang tag is a coding convention used on multilingual websites to indicate the language used and the target country. Its role is to inform browsers and search engines that there are multiple versions of a webpage for different languages ​​and countries, allowing users to view the appropriate page.

Benefits of setting hreflang tags

  • Optimized search results: Search engines can correctly recognize the target language and region of each page, making it easier for pages relevant to the user's language and region to appear in search results.
  • Avoiding duplicate content penalties: By properly setting hreflang tags, the same content in different languages ​​will be recognized by search engines as multilingual content, reducing the risk of being penalized for duplicate content.
  • Improved customer experience: Pages are optimized for the user's language and region, allowing customers to easily find the information they need, leading to increased convenience and customer satisfaction.

How to set up hreflang tags

There are mainly three ways to configure hreflang tags:

  • Set using HTML tags
  • Set in HTTP headers
  • Configure it in the sitemap.

A common method for setting hreflang tags is to use HTML tags. HTML refers to the language used when creating websites. Open the HTML file of the page you want to make multilingual, and add an hreflang tag like the following within the <head> tag.

<link rel="alternate" hreflang="ja-JP" href="/jp"/>

This syntax consists of the following three elements:

  • link rel="alternate": Informs search engines that there are pages with the same content but in different languages ​​and regions.
  • hreflang="language code-country code": Specifies the target language and region.
  • href="URL": Specifies the URL of the target page.

The example above indicates that the page is written in Japanese and intended for a Japanese audience.

Additionally, you can set a default page for users who do not belong to any language or region by adding the following values.

<link rel="alternate" hreflang="ja-JP" href="/jp">

The main language codes and country codes that can be used in hreflang settings are as follows:

Language code

Chinese (Traditional)

zh-Hant

Simplified Chinese

zh-Hans

German

French

Spanish

Italian

Portuguese

Country code

united states of america

England

France

Spain

Italy

Portugal

When providing multilingual support for non-HTML content, such as PDF files, you need to set the `hreflang` tag in the HTTP header. An example is shown below.

The code above supports four languages: Japanese, English, Chinese, and Korean.

When writing, enclose the URL in <>. Also, if specifying pages for multiple languages ​​or regions, separate each description with a comma.

Using a sitemap (sitemap.xml) allows you to communicate multilingual pages to search engines all at once. A sitemap is a file that tells search engines the URLs within your website. By setting hreflang tags in the sitemap, you can convey language and country information to search engines.

For example, to tell search engines about your English page for Canada, your French page for Canada, and your page for Australia, Shopify would add the following to its sitemap:

<url>

<xhtml:link

rel="alternate"

hreflang="en-ca"

hreflang="fr-ca"

hreflang="en-au"

<lastmod>2023-09-23</lastmod>

<changefreq>daily</changefreq>

<priority>1.0</priority>

</url>

When writing the code, specify the target page with <loc> and set the page for each language or region with <xhtml:link>.

Note that while `hreflang` can be set using only the language code, if you want to specify a country code, you must write the language code first, followed by the country code.

Points to keep in mind when setting hreflang tags

  • Pay attention to avoiding typos.
  • Set hreflang for all languages ​​on all pages.
  • Update as needed

To ensure search engines correctly understand your website's information, add hreflang for all languages ​​to every page. For example, if you operate a website that supports Japanese, English, and Chinese, you need to set the hreflang for Japanese, English, and Chinese on each page. It's especially important to be careful, as it's common to forget to set the hreflang for the base language, such as not setting the Japanese hreflang for a Japanese page.

When you add new pages or change the URL structure, you also need to update the hreflang. Furthermore, make sure to regularly check for configuration errors and broken links to keep everything up to date. Some CMSs (Content Management Systems) and e-commerce platforms automatically update hreflang, so it's a good idea to check beforehand whether automatic updates are enabled.

How to check hreflang tags

Once you've implemented hreflang, it's important to verify that it's configured correctly. There are two ways to do this: manual verification and using tools.

Manual verification method

  • How to check HTML tags: Use Google Chrome's developer tools to examine the source code and check if the hreflang tag is correctly written within the head element in the Elements tab.
  • How to check HTTP headers: Select the target file from the Network section in Developer Tools, and check if the Link header is correctly set in Response Headers within Headers.

How to check using the tool

Use the following tools to verify that hreflang tags are properly configured on a specific page or throughout the entire website:

  • SEOptimer Hreflang Checker
  • hreflang Tags Testing Tool (English)
  • hreflang.ninja (English)

Additionally, some SEO tools include a function to check hreflang, so it's a good idea to check if the tool you normally use has a similar function.

Please note that the International Targeting Report in Google Search Console, a commonly used method for checking hreflang, is no longer supported.

The hreflang tag is one of the international SEO strategies that indicates to search engines which country and language a webpage is targeting, thereby ensuring the site is displayed appropriately to the target users.

Setting hreflang tags not only attracts traffic from overseas, but also improves the user experience and helps avoid penalties for duplicate content. Use the methods introduced here to properly set hreflang tags and aim to operate a successful multilingual website.

Frequently Asked Questions about hreflang tags

What is an hreflang tag?

The hreflang tag is a coding convention used to inform search engines of the target language and region. When properly configured, it allows for the display of the most relevant pages to each user.

What are the benefits of setting hreflang tags?

  • Because search engines can correctly recognize the target language and region of each page, pages relevant to the user's language and region are more likely to appear in search results.
  • The same content in different languages ​​can be recognized by search engines as part of a multilingual strategy, reducing the risk of being penalized for duplicate content.
  • Because pages are displayed that are optimized for the user's language and region, customers can easily find the information they are looking for, leading to improved convenience and customer satisfaction.

What are some points to keep in mind when setting hreflang tags?

  • Be careful to avoid errors in language codes, country codes, URLs, etc.
  • Update as needed, such as when adding pages or updating the URL structure.

Share this article

  • Share on Facebook
  • Share on X
  • Share on LinkedIn

Related reading

View all
View offer
Shopify

Start free and explore current offers

Visit Shopify for trial duration, eligible plans and promotions available in your region.

Register free with ShopifyAffiliate disclosure