Hakyll post filename format

Tags: hakyll

By default the example site.hs deployed by Hakyll expects the filename to be in the form YYYY-MM-DD-STRING.EXTENSION. If you wanted filenames consistent with an alternative format YYYYMMDDHHMM.md the date parser does not understand dates in this form by default. Based on this conversation1 in the Hakyll Google Group from 2013 ‘published’ date meta data can be added to each post as an aternative. This can used to order posts if for example there is a recentFirst function call in your site.hs file.

This site uses a random filename string. For machines with Openssl or Libressl installed a pseudo random filename string can be generated using openssl rand -hex 8. The following shell script creates an empty markdown file in the current diectory with a random filename.

#!/bin/sh

filename=`openssl rand -hex 8`
touch $filename.md

  1. https://groups.google.com/g/hakyll/c/9EZ73CjsPko↩︎