1

I followed this setup in my sitemap that Google outlines on this page: https://support.google.com/webmasters/answer/189077?hl=en .

<url>
<loc>http://example.com/en</loc>
<xhtml:link rel="alternate" href="http://example.com/fr" hreflang="fr" />
<xhtml:link rel="alternate" href="http://example.com/de" hreflang="de" />
<xhtml:link rel="alternate" href="http://example.com/es" hreflang="es" />
<xhtml:link rel="alternate" href="http://example.com/en" hreflang="x-default" />
</url>

<url>
<loc>http://example.com/fr</loc>
<xhtml:link rel="alternate" href="http://example.com/fr" hreflang="fr" />
<xhtml:link rel="alternate" href="http://example.com/de" hreflang="de" />
<xhtml:link rel="alternate" href="http://example.com/es" hreflang="es" />
<xhtml:link rel="alternate" href="http://example.com/en" hreflang="x-default" />
</url>

However, should I also be including a "rel=canonical" tag like the following?

<url>
<loc>http://example.com/en</loc>
<xhtml:link rel="alternate" href="http://example.com/fr" hreflang="fr" />
<xhtml:link rel="alternate" href="http://example.com/de" hreflang="de" />
<xhtml:link rel="alternate" href="http://example.com/es" hreflang="es" />
<xhtml:link rel="alternate" href="http://example.com/en" hreflang="x-default" />
<xhtml:link rel="canonical" href="http://example.com/en" />
</url>

<url>
<loc>http://example.com/fr</loc>
<xhtml:link rel="alternate" href="http://example.com/fr" hreflang="fr" />
<xhtml:link rel="alternate" href="http://example.com/de" hreflang="de" />
<xhtml:link rel="alternate" href="http://example.com/es" hreflang="es" />
<xhtml:link rel="alternate" href="http://example.com/en" hreflang="x-default" />
<xhtml:link rel="canonical" href="http://example.com/fr" />
</url>

Thank you!

  • 2
    Where are you getting the idea that rel="canonical" is the thing to do? Canonical tags exist within HTML. I am not aware of canonical being for sitemaps. Cheers!! – closetnoc Mar 3 '16 at 22:00
1

It is always best to have a "rel=canonical" in the <head> of the HTML code in each page that you want the site crawled as. This means that if you are using a a separate site for desktop and mobile, and both pages point to the same content, always have the canonical link point to the address that you want the search engine to recognize and crawl. ie. www.example.org & m.example.org should both have a:<link rel="canonical" href="http://www.example.org/"> in the <head> of each page. The same would be for www.example.org/music.html & m.example.org/music.htm Each page should have a canonical link:

<link rel="canonical" href="http://www.example.org/music">

Search engine are well known to skip over sitemaps that have not been recently changed. That is why most are overlooking the <lastmod> and <changefreq> setting. They are basically saying, "I have this information, why do I want to see it again?" A sitemap is relevant, but your pages are priority.

To place the canonical link in both the HTML code and sitemap is overkill.

-1

The canonical and alternate tags IMHO should be used in the HTML of a page.

The sitemap should only contain the URLs that you want indexed.

So the sitemap should look like this:

<url>
<loc>http://example.com/en</loc>
</url>

All other URLs should not be included in the sitemap.

  • The way I created my Sitemap XML is based on what Google shows on this page support.google.com/webmasters/answer/2620865?hl=en – olimits7 Mar 4 '16 at 17:00
  • You didn't put this: <xhtml:link – CP3O Mar 4 '16 at 17:03
  • Oh ok, yes in this sample I didn't include it but in my real sitemap XML I have it listed that way. I updated this post to include this now so it looks right. – olimits7 Mar 4 '16 at 17:31
  • I think I will keep my Sitemap XML the way I currently have it; like I posted above in my original post. – olimits7 Mar 4 '16 at 17:33
  • However, I just noticed I don't have canonical showing on my HTML on my website. Should I be adding <link rel="canonical" href="domain.com/en" /> to my HTML and it will show the right information depending on the page the user is on? – olimits7 Mar 4 '16 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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