A couple of month ago I wrote that I switched to Pretzel to drive my site.

What I really like about Pretzel (except that it’s written in .NET) is that it is so easy to extend. You can write plugins either as a .NET assembly, or—even simpler—throw in an .csx file, because Pretzel supports ScriptCs.

One of the first extensions I wrote was a site map plugin. By default Pretzel already creates a site map, but only for static pages. Unfortunately, this doesn’t include paginated pages like the home page. Those pages are generated dynamically at runtime of Pretzel, and the default sitemap.xml doesn’t take those dynamic pages into account.

Therefore I wrote this plugin which creates the sitemap.xml including all generated pages, even the paginated ones. It uses the same technique as JekyllEngineBase.ProcessFile: for each post and page it adds an url entry to the sitemap. Additionally it checks the page’s front-matter if paginate is specified, and adds relevant URLs to the sitemap too.

The plugin is hosted on Github including some basic tests, but in fact you only have to copy Pretzel.Sitemap.csx to the _plugin folder of your Pretzel site.



Leave a Comment

Your email address will not be published. Required fields are marked *