June 06, 2005
Google SiteMaps for Movable Type - now with correct Last Modified dates

Google introduced SiteMaps a few days ago. SiteMaps lets webmasters inform search engines (not necessarily only Google) about which pages they have recently updated; expected update-frequencies as well as sender-set priority (i.e. if you have a couple of pages you consider a lot more important than others, Sitemaps lets you inform the search engine about it). Google does not necessarily adhere to your 'instructions' (i.e. if you set all your pages to priority 1, they will all be considered "average"; and if you set all your pages to "hourly" updates, don't expect the googlebot to come knocking unless you actually DO maintain your pages to this frequency...)

A couple of people have started playing with templating Sitemaps templates for blogging tools, especially Movable Type. I found the existing templates a bit too 'brute force' for my taste, as well as incomplete:

My view is that comments significantly enhance the value of an archived entry, so I'd want search engines to know about not only when I last edited an archived entry, but also when anyone last contributed to it. The correct way to implement this would take into consideration whether an entry has comments, and display the last comment date as "last modified" if present, otherwise it should display when the entry itself was last edited (disclaimer: yes you might sometimes edit an entry after last comment has been added, but in my case that is very rare and I can live with this known bug').

Additionally, the two other stabs at creating Sitemap templates for Movable Type don't take into account that you might want to assign different priorities and scan frequencies to your entries (as described here). The template below says that the blog front page has highest priority & scould be scanned daily. Next comes the ten most recent entries at priority 0.9, then the 10 next after that, and then "last 1000 entries" at priority 0.5. Modify numbers and priorities as you want & spread the word:

<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">

<url>
<loc><$MTBlogURL encode_xml="1"$></loc>
<priority>1.0</priority>
<MTEntries lastn="1">
<lastmod><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></lastmod>
</MTEntries>
<changefreq>daily</changefreq>
</url>

<MTEntries lastn="10">
<url>
<loc><$MTEntryPermalink encode_xml="1"$></loc>
<lastmod><MTIfNonZero tag="MTEntryCommentCount"><MTComments lastn="1"><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></MTComments><MTElse><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></MTElse></MTIfNonZero>
</lastmod>
<priority>0.9</priority>
<changefreq>daily</changefreq>
</url>
</MTEntries>

<MTEntries lastn="10" offset="10">
<url>
<loc><$MTEntryPermalink encode_xml="1"$></loc>
<lastmod><MTIfNonZero tag="MTEntryCommentCount"><MTComments lastn="1"><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></MTComments><MTElse><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></MTElse></MTIfNonZero>
</lastmod>
<priority>0.8</priority>
<changefreq>daily</changefreq>
</url>
</MTEntries>

<MTEntries lastn="1000" offset="20">
<url>
<loc><$MTEntryPermalink encode_xml="1"$></loc>
<lastmod><MTIfNonZero tag="MTEntryCommentCount"><MTComments lastn="1"><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></MTComments><MTElse><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$></MTElse></MTIfNonZero>
</lastmod>
<priority>0.5</priority>
<changefreq>monthly</changefreq>
</url>
</MTEntries>

</urlset>

Update: Cameron shows how to include monthly and category for those wishing to include them in the sitemap.

Sponsored links
Related Entries
Comments

Thanks for tracking back to my blog.
I readily used your template.

But, I thought the template has better using "<$MTBlogTimezone$>" after "<$MTEntryModifiedDate$>".
because I'm Japanese and local timezone is "+09:00", I need to change this part.

Just for information,Thank you.:-)

Posted by: yoshuki on June 7, 2005 06:05 PM

Google says mine has an "invalid date"

Any idea why?

Posted by: Hashim on June 7, 2005 07:16 PM

Hashim; the date format has to be ISO 8601:
http://www.google.com/webmasters/sitemaps/docs/en/protocol.html#xmlTagDefinitions
http://www.jacobsen.no/anders/blog/archives/2003/06/03/iso_8601_the_standard_date_format.html

Example:
2004-09-22T14:12:14+00:00 and 2004-09-22 are valid; but I'm not sure about 2004-09-22T14:12:14 (Google says you can publish without the time part, but it does not explicitly mention the time zone)

Posted by: Anders on June 7, 2005 07:20 PM

Yoshuki; you probably want to remove utc="1" if you set another time zone.

Posted by: Anders on June 7, 2005 07:27 PM

Hello, again.

I tried to remove 'utc="1"', but sorry, it was not correct format.
Help says,
https://www.google.com/webmasters/sitemaps/docs/en/protocol.html#sitemap_lastmod

and I changed
<$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%S+00:00"$>
to
<$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$>

If you have any idea about this else, please let me know.

Posted by: yoshuki on June 8, 2005 06:00 PM

This code works just fine. This is also the same code that is in the default RSS 1.0 template for outputting the date.
<$MTEntryModifiedDate format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$>

Posted by: Cameron on June 9, 2005 02:36 PM

Thanks for the template!

Posted by: Michael on June 10, 2005 03:17 AM

Excellent template! Thanks.

Posted by: Mary on July 1, 2005 08:20 PM

Hey Yoshuki,

I am also based in Japan and used the template code from http://www.cbulock.com/2005/06/sitemaps_-_latest_update.html which works with no problems.

I get 2005-07-25T17:19:41+09:00 in the xml output.

Posted by: Paul on July 26, 2005 05:36 AM

Hi
How do you think can i run blog from Samsung D500? :-\

Posted by: Melody Man on September 2, 2005 08:47 PM

ooops... sorry. It was comment for a post "Mobile Blogging"

Posted by: Melody Man on September 2, 2005 08:49 PM

Does it also make sense to add the Google Sitemap ping URL to the Movable Type preferences "Publicity/RemoteInterfaces/TrackBack" list? Would that work?

Posted by: Mecandes on November 21, 2005 10:53 PM

Hello, Ive found your interesting hack on delicious, and take contact with you to see if youd like to collaborate with our team in Schweiz for some major applications.
for some ideas see above page and click on editorial,
regards

Posted by: garik on February 7, 2006 11:09 PM
Post a comment
Name:


Email:
(Will not be displayed if you enter a website below. Otherwise, it will be displayed "spam protected")


Website:
(if you have one)


What do you want to say?
(please don't bother posting "spam" (pornography, viagra-sales etc - I will delete such comments anyway))


Remember info?



Referrers to this page
TrackBack URL for this entry:
http://www.jacobsen.no/cgi-sys/cgiwrap/anders/MT/mt-tb.cgi/1240
jdb cyberspace: Google Sitemaps and Movable Type (June 6, 2005 06:00 PM)
"Google Sitemaps is a new project from Google that aims to allow content creators to update the Google bots with information about site structure and update frequencies, among others. Google has made available a tool called Sitemap generator. Its writte..."
Cameron's Thought's: Sitemaps - Latest Update (June 6, 2005 07:05 PM)
"I have updated my sitemap and the new one is now based on Niall Kennedy's template that he created. This template outputs t..."
Gaziroh's Blog: MovableType で Googlebot 向けのサイトマップを生成 (June 7, 2005 01:46 AM)
"MovableType で Googlebot 向けのサイトマップを生成するテン..."
ProNet: Improved Google Sitemap Template (June 7, 2005 01:55 AM)
"Anders Jacobsen has just posted a new Google SiteMap template which adds correct Last Modified dates to the output. Combined with Cameron Bulock's templates for category- or date-based sitemaps, these new templates are even more full-featured than the ..."
mactobias: google sitemap 2 (June 7, 2005 11:27 AM)
"Google SiteMaps for Movable Type - now with correct Last Modified dates (Anders Jacobsen's blog) Anders Jacobsen merkt an, dass man die sitemap doch noch etwas feiner unterteilen könnte, als dass niall tut. in seinem template wird noch berücksichtigt..."
Neil's Smaller World: Google SiteMaps for Movable Type (June 9, 2005 12:38 AM)
"Improved Google SiteMaps implementation for Movable Type. Reminder for me for when I have some free time. [Via]..."
Murky.org: Sitemap (June 9, 2005 12:02 PM)
"Thanks to Anders Jacobsen and Cameron, this site now comes equipped with a Google Sitemap for faster indexing. The sitemap is available here, and should hold no interest for any human reader unless they run a blog. For anyone who..."
UtterlyBoring.com: CSS, Web/Print Design, Freelancing Link Dump (June 10, 2005 06:16 PM)
"Just a pile of links that I'm dumping here, primarily for my future reference, but they might come in handy to somebody here. CSS Cheat Sheet Jello CSS Layouts Tips..."
All things Bru: Etching a new template (June 12, 2005 02:19 PM)
"The time has come to rethink the layout of ATB. A few considerations: . I still love the "bleached" look. . Orange for links is growing a little too "worn", and in Italy I've seen that Mantellini uses it, maybe I'll leave while the tide is high. By the..."
simoncox.com sideblog: Google site maps (June 12, 2005 07:57 PM)
"Interestingly Google have just released a new site map protocol using xml. I am sure this will take off in a big way especially as we already have a templates for Moveable Type from the following - Niall Kennedy, Anders..."
ResearchBuzz: Google Announces Google Sitemaps (June 13, 2005 11:43 AM)
"Google has announced Google Sitemaps, which is a free online service for Webmasters. The idea it that the better information Google has about a site the better and more completely..."
Abroadcast: Hemsidan - Google Sitemap (June 20, 2005 08:53 PM)
"För ett tag sedan såg jag att Google hade något som heter Google Sitemap, jag läste lite mer om vad det var och tyckte det skulle vara bra att använda till min hemsida. Hittade då denna sida: Google SiteMaps for..."
Michael Carpentier: Et hop, un Google sitemap dynamique pour Movable Type! (June 20, 2005 10:22 PM)
"Il y a quelques jours je parlais du nouvel outil de Google, le sitemap.xml, qui permettra aux moteurs de recherche d'atteindre l'ensemble d'un site facilement, même les pages "cachées" par les bases de données. Je l'ai donc implanté sur mon..."
Savoir: Google Site Map sur Movable Type (June 21, 2005 03:38 PM)
"Google SiteMaps for Movable Type - now with correct Last Modified dates (Anders Jacobsen's blog) Il faut modifier un peu pour MT 2.6 mais a fonctionne (les tags MTIfNonZero n'ont pas l'air tre supportes dans la version 2.6) pour..."
A Marketing Chick Diary: Free Google Sitemap Generators (June 22, 2005 05:02 PM)
"I just finished creating my first (test) Google Sitemap. It's interesting that although Google released their sitemaps on June 2nd, I've already found a variety of free scripts and software to generate these files. Wait! What's a Google Sitemap? With..."
the power house: Google Sitemaps (June 25, 2005 04:23 PM)
"For the power house, I'm now using a variation of templates from Anders Jacobsen and Cameron Bulock. <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url> <loc><$MTBlogURL en..."
simoncox.com sideblog: Google site maps (September 3, 2005 10:05 AM)
"Interestingly Google have just released a new site map protocol using xml. I am sure this will take off in a big way especially as we already have a templates for Moveable Type from the following - Niall Kennedy, Anders..."
Chris Abraham - Because the Medium is the Message: Google SiteMap for MT and WP (November 21, 2005 05:04 AM)
"If you would like to have the Google Site Map on your blog, it is super easy using Movable Type of WordPress...."
A Marketing Chick Diary: Free Google Sitemap Generators (December 10, 2005 11:30 PM)
"I just finished creating my first (test) Google Sitemap. It's interesting that although Google released their sitemaps on June 2nd, I've already found a variety of free scripts and software to generate these files. Wait! What's a Google Sitemap? With..."
姜源的WebLog: Google SiteMap模板 For Movable Type (March 11, 2006 01:12 PM)
"以前在Bo-blog里做SiteMap是自己写php程序生成的,现在用MT了,正想着是否需要补习一下Perl来着。可轻易就google到了sitemap的模板。原来世界真是美好哈.....具体模板文件在如下链接里: Google SiteM..."

21389 visits (16 today, 87 this week)

© Anders Jacobsen
[weblog / photography]