Let Movable Type Generate Your XML Sitemap with a Custom Index Template

| No TrackBacks
Many sites are moving towards dynamic XML sitemaps.  These sitemaps let you tell Google, Yahoo, Bing, and Ask.com which pages on your site they should index, how often, and when they were last modified.  You can even assign a priority to each page in the sitemap, which serves as an indication of how important a specific page is in relation to others.

The sitemap protocol is well defined here at sitemaps.org.

Yesterday, I configured Movable Type, my blog publishing platform, to automatically generate my own sitemap.xml when I publish a new page or blog entry.  I added a custom Movable Type Index Template that would automatically generate a complete sitemap.xml for me, and place it under the root of my blog at http://mark.koli.ch/sitemap.xml.


1- My Sitemap XML Index Template

My custom sitemap XML Index Template is relatively straightforward.  In my Movable Type control panel, I clicked "Create index template" on the Blog Templates screen.  I named my template "XML Sitemap" and used the following configuration:

<?xml version="1.0" encoding="<$mt:PublishCharset$>"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<!-- blog root -->
<url>
<loc><$mt:BlogURL encode_xml="1"$></loc>
<lastmod>
<mt:Entries lastn="1">
<$mt:EntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$>
</mt:Entries>
</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>

<!-- pages -->
<mt:Pages lastn="0">
<url>
<loc><$mt:PagePermalink$></loc>
<lastmod><mt:PageModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></lastmod>
<priority>0.8</priority>
</url>
</mt:Pages>

<!-- entries -->
<mt:Entries lastn="0">
<url>
<loc><$mt:EntryPermalink encode_xml="1"$></loc>
<lastmod><$mt:EntryDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></lastmod>
<changefreq>never</changefreq>
<priority>0.6</priority>
</url>
</mt:Entries>

<!-- archives -->
<mt:ArchiveList archive_type="Monthly">
<url>
<loc><mt:ArchiveLink></loc>
<priority>0.4</priority>
<changefreq>never</changefreq>
</url>
</mt:ArchiveList>

</urlset>

Using the sitemap XML protocol defined at sitemaps.org, I configured this template to include my blog root, all pages, all entries, and all archives in the sitemap.  I assigned a higher priority to my blog root and individual pages versus the entries and archives.  Note that I also omitted the <changefreq> tag under each "page", because I have no idea how often those pages will actually change.  Also, I intentionally omitted the <lastmod> tag under each archive page, since again, there's not point in defining the last modified date on an archive.

edit-template-xml-sitemap.png

Of course, you're free to change this template as you see fit as long as it adheres to the sitemap standard.


2- Submit Your Sitemap XML (Submission URL's)

Once you publish your sitemap with Movable Type, you'll probably want to alert Google, Bing, Yahoo and Ask.com that you've got a new sitemap.xml available for your blog.  As described here in the sitemap protocol, you can "ping" these web crawlers to alert them of the change.  To do so, copy and paste these URL's into a web-browser, and replace <sitemap URL> with the full URL to your new sitemap:

http://www.google.com/ping?sitemap=<sitemap URL>
http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=<sitemap URL>
http://submissions.ask.com/ping?sitemap=<sitemap URL>
http://www.bing.com/webmaster/ping.aspx?siteMap=<sitemap URL>

Example:

http://www.google.com/ping?sitemap=http://mark.koli.ch/sitemap.xml

On each submission, you should see some type of successful (HTTP 200 OK) response indicating that your submission was successful.  Here's what Google's looked like:

google-added-sitemap.png

Enjoy!

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on November 7, 2009 12:45 AM.

Onyx (beta) was the previous entry in this blog.

Rediscovering HTTP 410 Gone is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.