blog-thing - hello world!

Posted on - updated on

blog-thing is a pseudo "CMS" (content management system) and "static site generator" using git and a python script.


I wanted to write up my findings and experiences a blog, mostly as a exercise to collate my thoughts in order to express a newly learned topic in a cohesive manner.

Having had a look at the common blogging platforms I was not really happy with the all of the tracking and extra fuzz that came with them. I literally just want to present some text without enforcing anything on anyone that would happen to visit.

I didn't look very hard before deciding to write a system for myself. It aligned with my wishes of understanding an being in control of the whole process - and that's how I ended up with blog-thing.

writing a post

Each blog post is written as a separate markdown text file and committed to git. When the site is generated the script will look at all files in the posts directory and use their initial and last commit to extract "posted at" and "edited at" date/times.

This means you can work on your next blog post in a separate branch and "post" it when you are ready to merge it into your main branch.

And if you need to delete a post you can just run git rm

blog structure

All I am currently after is a front page to list the posts and the post themselves, resulting in two jinja2 templates, home and post. With the inheritance system on jinja2 there is also base template to declare the general stuff such as header and footer.

generating the site

The scripts is fairly straight forward. It uses the toml library to load configuration data and parse it in through pydantic classes. Based on the config it then finds the folder for the markdown blog posts.

To parse a markdown file there is some custom logic to return the elementree.Element which we will extract the first h1 element as the blog title from. All the relevant data for a post is collected into a Post object and stored in a list, sorted by the "posted at" time.

The front page template is given the list of posts to generate a index of titles and general info. Finally each post has its remaining XML tree rendered to HTML which is passed as content to the blog post template.


Not having the capacity to maintain a bare metal host myself I ended up provisioning a VPS on hetzner. Declaring the infrastructure as pulumi scripts and configuring the nginx service with ansible.