Sitemaps XML template for Roller 4.x
One of the benefits of using a CMS or blogging tool is that it should make generating a sitemap easy. Roller makes it very easy by using the velocity templating engine and exposing a lot of data via model objects. Below is a template that I have put together to generate the sitemap.xml for my site. To get the template to work I had to enable the SiteModel by adding org.apache.roller.weblogger.ui.rendering.model.SiteModel to rendering.pageModels in my roller-custom.properties file. The roller documentation has more details on enabling the SiteModel.
Using the sitemap template coupled with Google's webmaster tools I can
get an idea of the index coverage my blog is getting. As of publishing
this article about 90% of the pages in my sitemaps.xml are in the
Goolge index. I'm not sure how good 90% is in the scheme of things but at least now I have a base line to measure improvements in indexing.
<?xml version='1.0' encoding='UTF-8'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>$url.absoluteSite</loc>
<lastmod>$utils.formatDate($model.weblog.lastModified, "yyyy-MM-dd'T'HH:mm:ss'Z'")</lastmod>
<changefreq>daily</changefreq>
<priority>0.250</priority>
</url>
<url>
<loc>$url.home</loc>
<lastmod>$utils.formatDate($model.weblog.lastModified, "yyyy-MM-dd'T'HH:mm:ss'Z'")</lastmod>
<changefreq>daily</changefreq>
<priority>0.250</priority>
</url>
#set($pager = $site.getWeblogEntriesPager(-1,1000))
#set($entries = $pager.getItems())
#foreach($entry in $entries)
<url>
<loc>$url.entry($entry.anchor)</loc>
<lastmod>$utils.formatDate($entry.updateTime, "yyyy-MM-dd'T'HH:mm:ss'Z'")</lastmod>
<changefreq>daily</changefreq>
<priority>0.450</priority>
</url>
#end
#set($userpages = $model.weblog.pages)
#foreach($userpage in $userpages)
#if($userpage.navbar)
<url>
<loc>$url.page($userpage.link)</loc>
<lastmod>$utils.formatDate($userpage.lastModified, "yyyy-MM-dd'T'HH:mm:ss'Z'")</lastmod>
<changefreq>daily</changefreq>
<priority>0.450</priority>
</url>
#end
#end
#set($userCategories=$model.weblog.getWeblogCategories())
#foreach($cat in $userCategories)
<url>
<loc>$url.category($cat.path)</loc>
<lastmod>$utils.formatDate($model.weblog.lastModified, "yyyy-MM-dd'T'HH:mm:ss'Z'")</lastmod>
<changefreq>daily</changefreq>
<priority>0.450</priority>
</url>
#end
</urlset>