Trying out a flat-file blog

I recently completed Miguel Grinberg's excellent Flask Mega-tutorial so I wanted to add a bit more functionality to my website. But I didn't want microblogging; I can get that over on Bluesky. I wanted full proper blog posts where I could ramble at my leisure.

So I decided to make a quick feature to display longer-form posts in a way that lets me link and organize them more easily than just adding full pages to my website. I decided to just do them as flat files for now because that seems fairly simple to work on the programming side with while also letting me author posts in a fairly simple and intuitive way. I might make a separate feature where I store the posts in a database, but for now it feels like overkill.

Hit some fun catches along the way here; I first tried JSON since it's a pretty popular format but quickly realized that it was unsuitable for composing big multi-line text files like blogs, specifically when it comes to being able to easily write in a code editor or similar. Which is a shame since the rest of it is very convenient. I could have used a string to point to the markdown file for the content, but having to track two files independently seems a little cumbersome.

I'd heard about some programs for easily making websites based on flat files so I did a little research and found out about Hyde, which uses markdown files with YAML in front to define metadata. Figuring out YAML parsing and only getting it to hit the right parts of the file seemed like a little more than I needed, but the idea of a simple set of flexible key:value pairs delimited by some marker characters seemed like a good foundation, so I spun off my own verion. It's a bit ugly (I haven't had to write parsing for a while), but there's not a ton for it to do so for now I think it's fine.

Overall this was a fun little experiment; I'm sure I'll touch it up over time as I think of more things I want to add, but I was glad to get a chance to work on something slightly more elaborate in Flask.