A common question in multilingual WordPress websites is how to make sitemaps in different languages. Create a sitemap in two o more languages implies including additional attributes (hreflang tags), but sitemap plugins for WordPress don’t add these attributes. However some translation plugins include these annotations in header.
Introduction
A sitemap is a list of URLs of your WordPress website (pages, posts, categories, archives, etc). Sitemaps are usually made using two formats: HTML and XML.
- An HTML sitemap allows users to easily navigate a website. Users can go to the Sitemap to locate a page they are unable to find by searching or navigating through your website menus (Example: https://wplang.org/sitemap/)
- An XML sitemap is an easy way for website owners to inform search engines about all the pages and posts that are available on your WordPress site. XML sitemaps are submitted to search engines so they can crawl your website in a more effective way (Example: https://wplang.org/sitemap.xml)
1. What information can include an XML sitemap?
XML Sitemaps usually include a list of URLs and optional information about each URL such as:
- How important it is (priority of URL relative to other URLs)
- How frequently it changes (daily, weekly, monthly, never, etc)
- The date of last modification
- Images or videos included on each URL
Example of sitemap generated by WordPress SEO by Yoast:
However sitemaps also can include information about alternative language URLs in multilingual websites (hreflang annotation).
Example of sitemap generated by Sitemap Generator:
2. What is hreflang annotation?
One of the main difficulties with multilingual SEO is the successful targeting of the correct website to the correct country or region, so that search users in a country or region find the site that is aimed at them.
One useful solution to this problem is using hreflang attributes (rel=”alternate” hreflang=”x”). These attributes were released at the end of 2011 and updated in 2013 to support the x-default value. It’s used by Google (and Yandex) to correctly identify the language and also the country targeting of multilingual websites (Bing uses the “content-language” meta tag).
Imagine you have an English page at http://www.mydomain.com/, with a French version at http://fr.mydomain.com/
According to Google you can indicate that the French URL is equivalent of the English page using hreflang attributes basically in two ways:
- HTML link in header. In the HTML section of http://www.mydomain.com/, add a link element pointing to the French version of that webpage at http://fr.example.com/, like this:
<link rel=”alternate” hreflang=”en” href=”http://www.mydomain.com/” />
<link rel=”alternate” hreflang=”fr” href=”http://fr.mydomain.com/” />
This example shows a subdomain but it works across different domains or subfolders.
If you’re using in your website a translation plugin in a single WordPress installation (such as WPML or Polylang) or a translation plugin in a WordPress Multisite environment (such as Multilingual Press or Multisite Language Switcher), then you do not have to worry because these plugins can automatically include these attributes in your website header.
Example of this webpage:
- Sitemap. Instead of using an HTML link in header, you can include language version information in a Sitemap. An example:
IMPORTANT: Google recommends choosing only one way to implement hreflang annotations, in order to avoid errors.
3. How can you make an XML sitemap with alternative languages?
The first option is create your sitemap manually following Sitemaps XML protocol, but this can be time-consuming.
It’s much better to use a WordPress plugin or a special software to create sitemaps automatically.
3.1. WordPress plugins
There are different plugins to create a sitemap in WordPress. I use Yoast’s WordPress SEO plugin, since it has a section for this purpose and unlike other plugins includes images (Go to SEO > XML Sitemap and enable Sitemap functionality). Anyway there are other sitemaps plugins: Google XML Sitemaps, Better WordPress Google XML Sitemaps, XML Sitemap & Google News feeds or Google Sitemap by BestWebSoft.
These plugins include in sitemaps information about priority, change frequency and the date of last modification (WordPress SEO also includes images), however none of them include hreflang tag for language URLs.
Solution:
- Using a sitemap plugin, such as WordPress SEO or Google XML Sitemaps
- And a translation plugin that adds automatically hreflang annotations in the header of your website
3.2. Software
Another option is choosing from a number of third-party tools to generate your sitemap automatically.
The only software I’ve found that includes hreflang in sitemaps is a paid solution called Sitemap Generator that costs $19.99 (free version doesn’t include hreflang tag in sitemap). It’s a php script which is designed to run on the server that hosts your website. It is another option that you can use on your multilanguage WordPress website.
It generates any kind of sitemap: XML, HTML, text formatted, mobile sitemap and optional extras such as images sitemap, video sitemap, news sitemap or RSS Feeds.
Anyway this software automatically detect hreflang from your website, but also you can specify manually alternative language versions for your posts and pages. Install this software on the server that hosts your website, log in http://mydomain.com/generator and go to Configuration > Advanced Settings > Include hreflang for language URLs in sitemap.
Note that Google strongly recommends that you choose only one way to implement hreflang tags, in order to avoid inconsistent signals and errors, so if you are going to use this software, you should avoid that your translation plugin displays hreflang in the head section. For example, WPML has this option, just go to WPML > Languages > SEO Options and uncheck the box “Display alternative languages in the HEAD section”:
4. How to manage multilingual sitemaps in Google Webmasters Tools?
Search engines are very smart in finding a sitemap. However, it is always advisable that you submit your sitemap to search engines by using webmaster tools. The benefit of this is that search engines will now show you pages indexed, any errors, and other relevant information that will be helpful.
4.1. Subdirectories or subfolders
If you use subdirectories or subfolders you will have a single domain in Google Webmaster Tools, but note that you can add subfolders (or subsites) in Google Webmasters Tools as a separate sites.
Webmaster Tools data and reporting work best on a site level. For example, if your site http://www.example.com has separate sections for different countries, we recommend adding each of those subsites or subfolders as a separate site. For example, if you have a travel site with specific subfolders covering Ireland, France, and Spain, you could add the following sites to your Webmaster Tools account:
http://www.example.com
http://www.example.com/france
http://www.example.com/ireland
http://www.example.com/spain
This means that if you are using subdirectories for each language, then it is advisable to add each of them on Google Webmasters Tools. This way you can use International Targeting section in Google Webmasters Tools on each subdirectory.
WordPress single installation
If you’re website is using:
- Languages in subdirectories (http://mydomain.com/fr)
- A WordPress single installation
- A translation plugin (WPML, Polylang, etc)
- A sitemap plugin (WordPress SEO or Google XML Sitemaps)
Then you may create one sitemap in the primary domain (http://mydomain.com) and submit to Google Webmasters Tools. This sitemap will include all the URLs mixed in different languages.
Go to Site dashboard > Crawl > Sitemaps > Add/Test Sitemap (red button):
A very common case is using WordPress SEO by Yoast and WPML.
For example, WPML website is using WordPress SEO by Yoast for sitemaps and WPML as a translation plugin. As you can see in the screenshots, sitemaps generated mix URLs in different languages, but this is not a problem since in header are included hreflang attributes.
- Global sitemap: http://wpml.org/sitemap_index.xml
- Page sitemap 1: http://wpml.org/page-sitemap1.xml
And if you have a look at the HTML code:
WordPress multisite
If you’re website is using:
- Languages in subdirectories (http://mydomain.com/fr)
- WordPress multisite
- A translation plugin (Multilingual Press or Multisite Language Switcher)
- A sitemap plugin compatible with WordPress multisite (WordPress SEO or Google XML Sitemaps)
You should activate your sitemap plugin for the entire network of sites and create a sitemap for each site (and language). One for your French version, one for your Spanish version:
- http://www.mydomain.com/fr/sitemap_index.xml
- http://www.mydomain.com/es/sitemap_index.xml
- http://www.mydomain.com/de/sitemap_index.xml
- Etc…
And submit them one by one in Google Webmasters Tools.
4.2. Domains or subdomains
In this case you will have different domains or subdomains in Google Webmasters Tools. Note that Google consider subdomains as separate sites in Google Webmasters Tools (you should add each subdomain in webmasters tools).
If you’re using domains or subdomains for different languages, then you need to create different sitemaps for each domain or subdomain, and submit them separately.
Activate your sitemap plugin for the entire network of sites and create a sitemap for each domain or subdomain.
Example:
- https://wplang.org/sitemap.xml (English)
- http://es.wplang.org/sitemap.xml (Spanish)
- http://de.wplang.org/sitemap.xml (German)
Hreflang annotations in header:
5. How can I know if I’m using hreflang correctly?
When you configure hreflang annotations, Google finds them on your website and crawls the corresponding URLs referred to by the tags, reporting errors.
This helps you maintain a healthy international presence so that search results for your visitors display the language and country variant you want them to see
In Google Webmasters Tools, you can use two sections in the International Targeting page: Language section and Country section. Just go to your Site dashboard > Search Traffic > International Targeting.
5.1. Language section
This section helps you ensure your hreflang tags use the correct codes (language and optional country).
This section can displays two common errors in multilingual sites:
- Missing return tags from alternate languages. For every language code and alternate URL, Google checks that the alternate page has a return tag that links back to the page or post on your site. This is the most common error for international sites. You can inspect details by clicking on an error. While writing this article I realized that the English version of this blog has errors on some hreflang tags:
- Unknown language codes. In case you’re using an incorrect or unknown language code in your hreflang attributes.
The value of the hreflang attribute identifies the language and optionally the region of an alternate URL. For example:
de: German content, independent of region (list of language codes)
de-CH: German content, for users in Switzerland (list or regions codes)
More info about errors: Troubleshooting hreflang annotations in Webmaster Tools. Official Google Webmaster Central Blog
5.2. Country section
You can use the Country section to set a site-wide country target for your entire site, if necessary.
From the International Targeting section, go to the Country tab and choose your country target.
This is important if your site has a generic top-level domain ( .COM, .ORG, .NET, etc), and targets users in a particular country or regional location. This improves search results for geographic or regional queries.
If your site has a country-coded top-level domain (.ES, .FR, .RU, .DE, etc) it is already associated with a geographic region (Spain, France, Russia, Germany). In this case, you won’t be able to specify a country location.
In other cases, if you don’t want to associate your site with any country, do not check the box “Target users in” or just select “Unlisted”.
For example:
- English version of this site is not associated with any country, because it is aimed at everyone speaking English regardless of the country
- Same happens with the Spanish version, since it is aimed at Spanish-speaking people, not only Spain but countries in Latin America
I hope this post has helped you understand how you can make sitemaps in WordPress in multiple languages. Thanks for sharing!
References:
- Using the Correct Hreflang Tag: A New Generator Tool. The Moz Blog
- Case Study: The Impact of HrefLang Tag. SEER Blog
- How To Implement The hreflang Element Using XML Sitemaps. Search Engine Land Blog.