Static websites with Zola

  1. Zola a static site generator
    1. Zola commands
    2. Building a site with Zola

Zola a static site generator

This post is about Zola, a static website generator and will show you how to make your first Zola post.

Zola is a static site engine written in Rust. The big advantage of static websites is, that they are fast and take advantage of caching. That's because the webserver only has to serve static rarely changing files and not make dynamic lookups against a database or execute scripts. OpenBSD's httpd is a good choice for a server serving static files.

With Zola all commands are compiled into one binary, so there are no dependencies except Rust. I like it because it is very easy to use and very fast, especially for small sites. The CLI is intuitive and building your site takes just some milliseconds. In essence Zola just stays out of my way, that's how i like it . That way I can focus on content rather than being distracted by an unintuitive CLI or reading docs.

Featurewise it is almost the same as Hugo, for a comparison see this link. Zola mainly uses a different template engine and a different file format for configurations files, namely TOML instead of YAML, quick comparison here. Also Zola supports Sass which makes CSS suck a little less. Zola's commands are pretty self-explanatory:



Zola commands

Initialize a directory for Zola:

$ zola init

Build the site:

$ zola build

Check for errors:

$ zola check

Build and serve the site locally, useful for debugging (by default at 127.0.0.1:1111):

$ zola serve



Building a site with Zola

First install Zola:

$ sudo apt install zola

To use Zola you have to initialize a directory first:

$ zola init mywebsite

For convenience install a theme:

$ cd website/themes
$ git clone https://github/myzolatheme

Edit the config.toml and set the preferences to your liking. And write your first post:

$ vim content/myfirstpost

You don't have to add metadata to your posts but the opening/closing +++ (brackets) are required. myfirstpost:

+++                                 
title = "My first post with Zola"   #optional
+++                                 

You can serve the site locally to see what it looks like:

$ cd website
$ zola serve

Finally build the site with:

$ zola build 

Now host your website directory with your favorite webserver and enjoy the loading time of a static website.