I recently moved my blog from the VPS that I used for over a decade to GitHub Pages. They’re really cool, especially the automagic deploys of the magic gh-pages branch. But, they were missing one feature I sometimes use: directory listings (because sometimes I’m lazy). I would write a Jekyll plugin, but GitHub Pages does not run arbitrary plugins.
I came up with an embarrassingly hacky solution that I thought I’d share.
Create a file named
_makeindex.sh with this content. Start it with an underscore to prevent Jekyll from serving it.
- Tweak the
grepstatement in the first line to display what you want to serve.
- Run the script before you deploy.
- Feel dirty for doing something so hacky. Wash with extra soap.