Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multilingual sitemap.xml file

I have a website that has more than 1 language and I would to optimize my sitemap.xml so it will include all available languages - I found this guide on Google Webmaster Tools to use XHTML to provide all available URLs (one for each language) and this breaks the XML file, I've changed the properties to as described but it's still broken - not Chrome, Firefox or IE is able to read the file correctly.

Is this normal?

Here's an example of a sitemap.xml given by Google Webmaster Tools:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>http://www.example.com/english/</loc>
    <xhtml:link rel="alternate" hreflang="de" href="http://www.example.com/deutsch/"/>
    <xhtml:link rel="alternate" hreflang="de-ch" href="http://www.example.com/schweiz-deutsch/"/>
    <xhtml:link rel="alternate" hreflang="en" href="http://www.example.com/english/"/>
  </url>
  <url>
    <loc>http://www.example.com/deutsch/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="http://www.example.com/english/"/>
    <xhtml:link rel="alternate" hreflang="de-ch" href="http://www.example.com/schweiz-deutsch/"/>
    <xhtml:link rel="alternate" hreflang="de" href="http://www.example.com/deutsch/"/>
  </url>
  <url>
    <loc>http://www.example.com/schweiz-deutsch/</loc>
     <xhtml:link rel="alternate" hreflang="de" href="http://www.example.com/deutsch/"/>
     <xhtml:link rel="alternate" hreflang="en" href="http://www.example.com/english/"/>
     <xhtml:link rel="alternate" hreflang="de-ch" href="http://www.example.com/schweiz-deutsch/"/>
  </url>
</urlset>
like image 241
nirpeled Avatar asked Dec 02 '13 14:12

nirpeled


1 Answers

such an old question but it popped up high on my results looking for something similar before.

So no, it's not normal but yes the sitemap.xml will still be valid. The xml schema doesn't include the xhtml:link namespace if I understand correctly.

It seems that Google recommends the incorrect thing and that others are implementing their advice such as the sitemap npm package

I've gotten it to work with this code:

<urlset
  xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
                      http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
                      http://www.w3.org/TR/xhtml11/xhtml11_schema.html
                      http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd"
  xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html"
  xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
  xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"
  xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
  xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">

even google themselves have an improper sitemap

like image 139
flowen Avatar answered Sep 19 '22 11:09

flowen