You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

3.1 KiB

title date
ANOTHER Static Site Generator, C++ version 31-01-21

I fear this blog is reaching a critical-mass of posts about its static site generator (SSG). Especially given its pageview count is about 1 a quarter, which is probably me.

For the past year it has been built using a Python script and pandoc. Recently I decided to write a more substantial SSG in C++, using the multimarkdown parser library, which is implemented in C.

Largely this was inspired by multimarkdown's 10ms/page render time brings the compile time of the website from around 5 seconds to 200ms. It also allows it to be built entirely in memory without having to use temporary files or caching (I could do that with pandoc if I wanted to redirect stdin and stdout) -- largely it is because I want a more maintainable project. Even C++ code is more rigid than Python.

Despite this of course, I cannot escape the question: Does the world need another static site generator, and what makes this any different to Hugo or Jekyll?

The first part, I cannot really provide a good answer for---but it isn't enough to stop me from writing it anyway. I would like to have my own solid SSG regardless of whether it really brings anything new. It has at least fixed the bugs in the Python version.

The main idea is that the file tree should be the main way of categorising content: not tags, post categories, blogs, et cetera. As such the core design considerations were:

  1. Be able to run it in an arbitrary directory and generate a website site without providing a lot of configuration: do not assert any structure on the files and directory tree of the source, and leverage the filesystem as much as possible.
  2. Be simple to template: templates are part of the same source code as the content. It should be completely out of the way except when you want to give it a nudge towards some specific behaviour.
  3. Be complete as a single binary: bundle dependencies and be self-documenting.
  4. Be easy to port to Windows and Mac, be fast, small and simple as possible.

This list is largely inspired by the design philosphy of 100 Rabbits, which I came across recently and found to have succinctly summarised the characteristics of the software I like to use and create. And, I find most of the software annoyances I regularly face are the complements of their list: software that needs the internet to function, hampered by DRM and activation key servers, distribution systems that break once they become 2 versions out of date, and unneccessarily high CPU and energy resource requirements.

Regardless, here is the code and what it does.

The notable features that are currently missing are

  • A watch and update mode
  • A built in server
  • RSS/Atom Feeds

I do not have immediate plans to add these.

For more on building pointless static site generators consider reading this article. It was at least some of the inspiration for writing mine.

WHY C++?

Because I want to learn it.