I came up with a shell script to generate a XML sitemap for my site.
Why a shell script? My whole website is built with shell scripts and a makefile.
My static site generator is a MEWNIX system; my cats know this.
Here’s sitemap.sh if anybody needs it.
#!/usr/bin/env bash
LASTMOD_DATE=$(date -u -Iseconds)
ENTRIES=$((find site -name '*.html' && find site -name '*.xml') \
| sort -u \
| awk -F '\t' '{printf "\t<url>\n\t\t<loc>%s</loc>\n\t\t<lastmod>__DATE__</lastmod>\n\t\t<changefreq>weekly</changefreq>\n\t</url>\n", $1}' \
| sed -e "s|site/|${URL}/|g" \
-e "s|__DATE__|${LASTMOD_DATE}|g")
cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${ENTRIES}
</urlset>
EOF