Friday, 13th May 2022
The popularity of static site generators tells me that a lot of people just want to write markdown and serve its HTML directly from their webserver.
Does that describe you? Well put that bloated site generator down! Because Apache will happily serve your markdown as HTML - on demand - without the need to fill your harddrive with a static site generator and its thousands of outdated NPM dependencies.
Just enable the ext_filter module:
Install a markdown to HTML conversion tool:
And add a new output filter to your site config:
Now you can drop .md files directly into your server's DocumentRoot and visit them in your browser to see the HTML!
This is just meant to be a bit of fun - but if you do want to try this in production, I suggest you cache the generated HTML. The conversion is usually very fast, but caching means Apache won't have to start a markdown process for each request.
Enable Apache caching modules:
Add caching to the site config:
This should give you performance plenty good enough for a personal site.
You probably also want to swap /usr/bin/markdown for a script that outputs a complete HTML document (including a <title> etc.). You might find Pandoc with the --standalone flag can help with that, but I'm leaving it as an exercise for you, dear reader.
Have fun playing with Apache - it can really do a lot of stuff! Try adding server-side includes for the full site-generator experience.