4 ms·
> Maybe it would be nice to write articles in markdown and have a custom static website generator that takes these and publishes them. This is what I do. I ha
by barrucadu 5y ago
> Maybe it would be nice to write articles in markdown and have a custom static website generator that takes these and publishes them.
This is what I do. I have three static websites, each has a small (few hundred lines of code) Python script rendering them. I find it worlds easier than existing static site generators, where going even slightly off the happy path is usually a huge pain.
Some examples of custom things I've implemented, which were basically trivial due to doing it myself:
- A probability table renderer, which produces output like https://i.imgur.com/siNN5Tu.png https://i.imgur.com/siNN5Tu.png from a CSV of values and probabilities.
- A custom syntax for acronyms, which get the mouse-over text and a link to a glossary entry inserted (with automatic pluralisation too).
- Custom rules for rendering markdown code blocks, to handle things like rendering GraphViz code to an SVG and inserting that in the page.
I usually use jinja2 for templating and pandoc or pymarkdown for rendering the content.
I've intentionally NOT made one static site generator to handle all three sites, as this is where the complexity and inflexibility of existing static site generators comes from. Specialised tools which can evolve independently are inherently more flexible than one complex tool which tries to do everything.
People often say that using a pre-existing static site generator means you don't have to implement features like hashing assets, rendering feeds, or handling tags/categories yourself. Which is true. But those are all very easy to implement, so it's not much of a selling point.