Data loading utilities

2024-05-29 11:25:00 +07:00 by Mark Smith

This post is part of the My static generator series. Follow the link to read the overview and get a complete list of posts.

The static site generator had been built initially to generate content websites' like blogs, linkblogs, newsletters, podcasts and notes. The posts of such websites tend to be written in markdown files. Though you can obviously store these in many different ways, one tried and tested way is to use a calendar folder structure.

An example of a blog post content markdown template showing the calendar folder structure:


Loading data from markdown files that are stored in such a folder structure is so common that I added utilities to the static site generator to load these files into memory. They are then made available to the templates being rendered at rendertime, sorted in various useful ways.

This makes it very easy to iterate over, for example, all the blog posts of a specific year and create an index page.

Frontmatter in markdown files is fully supported, and it's a great way to pass custom data into the render process.

For enquiries about my consulting, development, training and writing services, aswell as sponsorship opportunities contact me directly via email. More details about me here.