Making Your XML Sitemap a Little More UsefulPosted: Monday, February 21, 2011
I've had a sitemap for this site for quite a while. Google (and the various other search engines) loves them some sitemaps, since it helps them crawl your site a little faster and more efficiently. For those of you wondering what a sitemap is, it is a XML document that contains an element for every public-facing page in your web site. A good sitemap follows the standard setup by Sitemaps.org, a collaboration between Google, Yahoo, and Microsoft to establish a standard sitemap format. You can deviate from the sitemap protocol if you're feeling rebellious, but the search engines will respond by ignoring your sitemap (and perhaps your site in the process).
One problem with sitemaps (and XML documents in general) is that they aren't exactly great to look at. A seasoned coding warrior can probably get what they need from viewing a XML document, but for those of us that like things to be a little nicer to read, an HTML version of a sitemap would be wonderful. A HTML sitemap is not a valid sitemap for search engines, though, so what to do? Hmm...
To our rescue comes an often-overlooked sibling of XML: XSL. XSL stands for EXtensible Stylesheet Language. What it does is to let us create a series of transformations we can apply to our XML document. Or, as w3schools puts it, "XSLT transforms an XML document into another XML document." So what, you say? It is still an ugly old XML document, you say? Maybe, but I know of a type of XML that I'm particularlly fond of... XHTML.
That's right, XHTML.
Bet some of you forgot that XHTML was created to blend the rigor of XML with the presentation aspects of HTML, didn't you? No worries...
And that brings us to the main topic of this post: making our sitemap more useful. With a XSL document, properly linked to our XML sitemap, we can transform the sitemap into a XHTML page that us humans can read, and the search robots will still get the valid XML document that they came for. Pretty neat, huh?
needs to be updated to
as the original markup makes a reference to an external file that doesn't seem to be available any longer. I also like to limit my external dependencies, so I would probably have changed that link anyway.
If you updated your sitemap correctly, and everything is in place, you should see something similar to my sitemap, found at http://tiesontrowbridge.com/sitemap.xml. That's it. You're done. For the minimum amount of effort we just expended, we get well-formatted, easily-read sitemaps. And that's just freakin' cool...