I made a simple static site generator for my new blog incarnation. The generator works using Markdown and lxml to generate sites. I am not using any normal templating tools like jinja or mustache.
Since I think it's kind of interesting, articles are structured as separate files in a directory, and an article itself looks like this:
metadata, e.g. the article date
more metadata
blog content starts here
In other words, there is a preamble section of metadata, a blank line, and then the actual markdown text. I parse the metadata, generate HTML using the Python markdown module, and then transform that into an lxml element tree. The lxml element tree is munged to insert the metadata (e.g. the article date).
I decided on this format because
- I like writing and editing markdown, and in particular Emacs has good support for editing markdown.
- The preamble format is easily extensible, e.g. in the future I can add arbitrary metadata such as information about when articles were updated.
- Using lxml to generate the output, instead of a normal Python templating tool, forces me to keep the logic and emitted HTML ultra simple. The lxml module is very powerful but also quite byzantine which is an intentional choice.
Mostly I intend on using this space to talk about music, bicycles, computers, life, work, and all of that good stuff.