2

Following Google guidelines for creating an sitemap.xml file to add a href lang annotations, I'm getting display issue when viewing the sitemap.xml file in my browser.

Instead of looking like a normal xml sitemap, it just displays like text on a single line:

enter image description here

I think this is just a display issue, if you view source it looks fine and all data is there, it also tests in GWT with no errors, but what is causing it to displays like that?

Here is an example of the code:

<?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/en/</loc>
<xhtml:link rel="alternate" hreflang="en-sg" href="http://www.example.com/en/" />
<xhtml:link rel="alternate" hreflang="en-ph" href="http://www.example.com/ph/" />
<xhtml:link rel="alternate" hreflang="en-my" href="http://www.example.com/my/" />
</url>
<url>
<loc>http://www.example.com/ph/</loc>
<xhtml:link rel="alternate" hreflang="en-sg" href="http://www.example.com/en/" />
<xhtml:link rel="alternate" hreflang="en-ph" href="http://www.example.com/ph/" />
<xhtml:link rel="alternate" hreflang="en-my" href="http://www.example.com/my/" />
</url>
<url>
<loc>http://www.example.com/my/</loc>
<xhtml:link rel="alternate" hreflang="en-sg" href="http://www.example.com/en/" />
<xhtml:link rel="alternate" hreflang="en-ph" href="http://www.example.com/ph/" />
<xhtml:link rel="alternate" hreflang="en-my" href="http://www.example.com/my/" />
</url>
</urlset>
  • I also created an xml sitemap file using Google's exact example and it had the same issues, so I know it's not something in my code. Still interested in why it displays as such though. – Max May 11 '15 at 4:29
  • By default, XML files aren't meant to be displayed in a browser. They're meant to be read by code, not users. This is why your browser displays it as a single line. You can add an XSL file (see google.com/search?q=sitemaps%20xsl ) if you want to make it more readable, but it's really not something you should need to look at in a browser. – John Mueller May 13 '15 at 15:01
  • Thanks John, but why does a 'normal' xml sitemap file display correctly in browsers without using XSL? It just seems to be href lang xml sitemaps that display like that. – Max May 14 '15 at 2:59
  • Many mainstream sitemaps generators include a link to a XSL file by default, which is probably what you're seeing. – John Mueller May 15 '15 at 7:51

Your Answer

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

Browse other questions tagged or ask your own question.