Sitemap.xml Styling with JavaScript
What is this?
Every website that wants to be found should have a sitemap.xml file that Google (and other search engines) can use to help find and index
all the pages.
By default, these files look horrible when a human looks at them in a browser. But there is a simple way to make them look better: an XSLT Stylesheet from XML.Style!
How do I use it?
Add it to your sitemap.xml file. At the top of the file, it will
look like:
<?xml version="1.0" encoding="UTF-8"?> <urlset ...> ...
Add a line after the first xml tag (i.e. urlset):
<?xml version="1.0" encoding="UTF-8"?>
<urlset ...>
<script src="https://www.xml.style/sitemap/basic.js" xmlns="http://www.w3.org/1999/xhtml"></script>
...
Available Styles
Note: feel free to download them and host them yourself!
- basic.js - just a plain bullet list of pages with classless CSS.
Links
- Wikipedia entry for Sitemaps
- Sitmaps.org: the official specification for sitemap.xml
- Yoast: Why you need a sitemap
- Google: Building and submitting a sitemap
Copyright © 2026 Andrew Marcuse. All Rights Reserved. |
Source
| Share: