1

I have a multi-language website like this:

example.com/de/about
example.com/fr/about
example.com/about (English)

I decided to put the hreflang link elements in the <head> of each file. Now I wonder, is it enough to only put the default English URL in the sitemap like this:

<url>
  <loc>example.com/about</loc>
</url>

or do I have to put every language version in the sitemap:

<url>
      <loc>example.com/de/about</loc>
    </url>
  <url>
      <loc>example.com/fr/about</loc>
    </url>
  <url>
      <loc>example.com/about</loc>
    </url>

2 Answers 2

4

Wherever you put the hreflang is fine you have to use only one of the above methods. Find the methods suggested by Google here: Tell Google about localized versions of your page

Methods for indicating your alternate pages There are three ways to indicate multiple language/locale versions of a page to Google:

  1. HTML Tags
  2. HTTP Headers
  3. Sitemap

From personal experience i would suggest using the head method

Sitemap:

Pros: More control over which pages have alternative language Easy setup (crawl and set)

Cons: Monthly Update

Head:

Pros: Process can be automate by variety of plugins and scripts out there

Cons: You can end up easily have hreflang issues on pages without alternative language (unless is done manually ignore this)

Note: Im not really sure what happens if you keep both but i find that unnecessary, keep it simple and healthy to avoid errors and eventually google ignoring your hreflang.

Examples

Using hreflang on sitemap.

Sitemap should look like this:

<url>
    <loc>http://www.example.com/english/page.html</loc>
    <xhtml:link 
               rel="alternate"
               hreflang="de"
               href="http://www.example.com/deutsch/page.html"/>
    <xhtml:link 
               rel="alternate"
               hreflang="de-ch"
               href="http://www.example.com/schweiz-deutsch/page.html"/>
    <xhtml:link 
               rel="alternate"
               hreflang="en"
               href="http://www.example.com/english/page.html"/>
  </url>

Header shouldnt include hreflang since we have it on sitemap.

<head> no hreflang </head>

Using hreflang on header

Sitemap should look like this

<url>
    <loc>http://www.example.com/english/page.html</loc>

  </url>

Header should look like this:

<link rel="alternate" href="http://www.example.com/deutsch/page.html" hreflang="de">
<link rel="alternate" href="http://www.example.com/schweiz-deutsch/page.html" hreflang="de-ch">
<link rel="alternate" href="http://www.example.com/english/page.html" hreflang="en">
<link rel="alternate" href="http://www.example.com/english/page.html" hreflang="x-default">
4
  • So if use the head method you would not put <loc>example.com/fr/about</loc> into the sitemap? So you basically saying the opposite as Σπύρος Γούλας :D?
    – Adam
    Commented Oct 24, 2018 at 8:33
  • No, <loc> is a required tag for sitemaps you have to include that i may misunderstand your question sorry is morning over here :) If you are asking which version to include in <loc> then you must include your desired version it doesnt really make any difference i personally usually use the "en" or "x-default" - When Google is going through a website it visits first the robots.txt (where sitemap is declared) so it will return the correct hreflang no matter what you include in <loc>
    – John Could
    Commented Oct 24, 2018 at 8:39
  • Yeah sorry was unclear. What I meant is, you say its enough to put <loc>example.com/about</loc> in the sitemap and there is no need to put <loc>example.com/fr/about</loc> and <loc>example.com/about</loc> together in the sidemap -right? This would be the opposite of what Σπύρος Γούλας said.
    – Adam
    Commented Oct 24, 2018 at 8:43
  • Exactly if you dont use the sitemap to declare your alternative language then just put this: <loc>example.com/about</loc>
    – John Could
    Commented Oct 24, 2018 at 8:47
1

You have to specify each language specific url in your sitemap. Google has a post on its webmasters page that you can check. It has a specific section dedicated to sitemaps and localized versions of your site with a detailed example. In that section it reads:

You can use a Sitemap to tell Google all of the language and region variants for each URL. To do so, add a element specifying a single URL, with child entries listing every language/locale variant of the page including itself. Therefore if you have 3 versions of a page, your sitemap will have 3 entries, each with 3 identical child entries.

2
  • Thanks for your answer! Actually I was reading the same article and they say If you have multiple versions of a page for different languages or regions, tell Google about these different variations. [...] There are three ways to indicate multiple language/locale versions of a page to Google:. This is why I think it might be redundant to put language specific URL in sitemap and in the <head> of each file.
    – Adam
    Commented Oct 24, 2018 at 6:37
  • @Adam Indication apart, your sitemap should have all of your site's urls in it. Even when you don't need to specify localized content because you already do so in other ways, having all the different urls can be proven useful in scenarios like finding: actual number of site pages, crawling errors for different pages, number of indexed pages etc. In the end, specifying localized content in your sitemap is a "nice to have" even if you have already accomplished your goal of indicating localized content through other means.
    – Prinny
    Commented Oct 24, 2018 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.