Philipp Trommler's Blog

Sitemaps for (Small) Static Sites

You may know that I run a small CV site and since I'd like our precious observers to regularly scan my toy sites, I tend to provide a sitemap for them. I've implemented the updates of those sitemaps with a git commit hook I'd like to share with you here.

Published by Philipp Trommler. This article has also been translated to: de.

First of all, I've created a standard sitemap within the root of the repository that feeds my CV website. It goes like the following and should contain no surprises if you're used to them:

<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="">

Updating this file whenever I change something on my site seems like a cumbersome and error prone task, thus I've written a really small shell script that I use as a pre-commit hook by moving it to .git/hooks/pre-commit:


sed -i "s#<lastmod>.*</lastmod>#<lastmod>$(date --rfc-3339=date)</lastmod>#g" sitemap.xml
git add sitemap.xml

This script simply exchanges everything inside of <lastmod></lastmod> with the output of date --rfc-3339=date which is the current date in the format expected by the search engines and adds the resulting changes to the index. Therefore, the commit I'm currently editing automatically contains the current date within the sitemap.

Of course this solution doesn't scale well onto bigger sites, there you'd probably go better with a full fledged static site generator. But maybe you also have some kind of one-pager, portfolio site or online CV, that you want to upgrade with an automatic sitemap.

This was a rather short blog entry, but since I haven't written anything in quite some time I thought I share it with you nonetheless. If you have any improvements or found an error, please let me know!

Filed under Tiny Bits. Tags: web, git.

Want to comment on this article? Write me at blog [at] philipp-trommler [dot] me!

Articles from blogs I follow around the net

W3C Consortium and Financial Management RFP
via W3C News, May 20, 2020

As W3C moves toward a stand-alone Legal Entity we owe it to ourselves, our Members and our Community to explore the best way to run the organization and deliver the high-quality experiences that our community has come to expect. One of these areas is how …

Material of my talk at Embedded Online Conference 2020
via #embeddedbits, May 20, 2020

The Embedded Online Conference is an online conference for embedded systems, DSP, machine learning and FPGA engineers and it is starting today May 20th 2020.

Infra teams: good, bad, or none at all
via Writing - rachelbythebay, May 20, 2020

I'm used to working at companies which have "product" teams and "infra" teams. The "product" teams are the ones who think about what the end users will be doing to share cat pictures or order pizzas or do whatever they end up …

Generated by openring