creativespirit.tech/content/blog/site_generator.md

3.3 KiB

A Simple Static Site Generator

Why yet another site generator?

  • creativespirit.tech is about a concept. The software supporting the site implements that concept.
  • This site generator is quite barebone. Just a short script, actually. I could not find such a simple one anywhere.

Why not a static site generator like e.g. Hugo, Jekyll, Gatsby?

  • It would take too much time to figure out not just how to use, but how the thing actually works.
  • As they say Simple things should be simple, complex things should be possible. A basic site and blog should be easy & simple.

Why not a dynamic site, e.g. a server side generated site?

  • Have e.g. Python/Flask/Gunicorn/Nginx as reverse proxy, etc, for a simple site and blog? You must be kidding me.

What were your basic requirements for this small software?

  • Write content in .md, in a single dir, eventually with subdirs
  • Have a simple, easily tweakable md-to-html template
  • Use simple and sane styling; I chose a simple classless css theme/framework for this.
  • have a simple deploy model, e.g.
    • git pull on your server and then run a script
    • Or run the script locally and upload/copy (scp) your html files to your server.

So, smart-arse, what do you have?

  • Content dir, where all the markdown files go. You can have subdirs. If links between .md files work, then links of the generated HTML files should also work.
  • Same structure under the Nginx's /var/www/[yoursite]/html dir. E.g if you have subdirs blog and projects under content dir, you should also have subdirs blog and projects under /var/www/[yoursite]/html. (Here's an excellent article on installing and configuring Nginx for a basic static site.)
  • You have a site template under templates. It provides the HTML header and footer part of your pages. It also links to the stylesheets. The template is just several rows of HTML.
  • You have your styles under styles dir. These should also be placed under /var/www/[yoursite]/html/styles. Currently I use the excellent awsm.css.
  • You have your python script to generate the site under scripts. It is less than 100 LoC sparse python code. It should be very straightforward to understand and modify. Even the very basic recursion cannot make it too unintelligable :)
  • All these things are so taht you know, but to run the site generator you just use the ./run script

Do you think that having to manually create subdirs under content dir, having them also under Nginx tree, running bash scripts, etc is really simpler than the alternatives?

  • Maybe not. But if you want to have your site generated AND have simple styles and templates AND write content in markdown AND understand how this all works AND be able to tweak it easily, this piece of software might be something useful.