Setting up a blog

Published by Nicholas Pleschko on 2022-07-31

Why a static site generator?

I want to host a blog in a scalable and maintainable way. The only way for this blog to survive is if there is close to zero maintenance involved for me. The site should also be available around the world and without people having to pay or subscribe to any service (looking at you medium). The obvious solution is therefore to have a static site generator generate some HTML and host the site on a free hosting service like gitlab pages. So thats what I am going for.

But which static site generator to choose?

Looking at this huge list of static site generators can be overwhelming. Its easy to spend hours trying out different tools and getting lost in their documenation and that is exactly what I did. In the end I went for a single binary static site generator written in Rust called Zola

Setting up Zola

I set up a very simple Taskfile to manage the commands needed to generate the site like this:

# https://taskfile.dev
version: '3'

vars:
  ZOLA_IMAGE: ghcr.io/getzola/zola:v0.16.0

tasks:
  run_zola_command:
    vars:
      ZOLA_COMMAND: '{{default "Serve" .ZOLA_COMMAND}}'
    cmds:
    - docker run 
      -p 8080:8080
      -u "$(id -u):$(id -g)" 
      -v $PWD/src:/app
      -it
      --workdir /app
      {{.ZOLA_IMAGE}} {{.ZOLA_COMMAND}}
  init:
    cmds:
     - task: run_zola_command
       vars: {ZOLA_COMMAND: 'init'}
  build:
    cmds:
     - task: run_zola_command
       vars: {ZOLA_COMMAND: 'build'}
  default:
    cmds:
     - task: run_zola_command
       vars: {ZOLA_COMMAND: 'serve --interface 0.0.0.0 --port 8080 --base-url localhost'}

That allows me to just run task to serve the website locally. Or task build to build the website. Amazing 🎉