I was looking for a super simple/minimal static site generator that just does the bare minimum in terms of just rendering markdown and renders it on an html page. No backend server whatsoever, no crazy yarn/node libraries to generate pages, nothing. Super simple. No bullshit. It’s actually way harder than you probably think.

So I found ssg which is written completely in POSIX shell script. Using commands you more than likely already have on any UNIX-like system (and providing you have lowdown or Markdown.pl), it will take all your markdown in a src directory, render a common header/footer file in each one, and then spit them out into a destination directory. Super cool. Super simple. SUPER INSPIRING

I’ve started to make my own mods to it for my own sanity. They uhh, might not be completely POSIX compliant but in my case 99% of the time that won’t matter.

You can grab it from here.

Changes I’ve made to it below:
  • Used find when listing src files to also spit out the modified date for the sitemap.xml file (it used the current date, which TECHNICALLY would not be accurate)
  • Automatically adds a “Updated time” below each h1 tag per page using stat to get it from the source md file. Sometimes you just gotta know when something is updated, ya know? (It won’t do this on the index/home page)
  • Fixed page titles not generating correctly if a title already existed (this was more on me for not realizing how it worked, but fixed the edge case anyways)
Thoughts/ideas on improvements:
  • Make minimal ’template language’ while still using bash/shell to compile together. For example, if you put %%SSG_RECENT%% in your template, then on render it could turn that into a ul list of recent page updates (which we technically already get for the sitemap).
  • Find a ‘smart’ way to have all external links to open in new via adding target="_blank" dynamically if not relative to the base_url. (Don’t know if I want to do this tbh, but its mostly done)
  • Add in support for less/scss or some kind of quick css preprocessing for fun. Something something “if .scss or .sass file exists, render to CSS in the dst. If we’re already using markdown to minimize writing HTML, we might as well do this too?