Infinitum Finis Design

Website Deployment

2020-04-20 // Robin // 4 minutes

This insight highlights the deployment for publishing new content onto my website. At first the prerequisites will be shown and after that the steps for pushing new content onto the server.


The following programs are required:

  • Git
  • Zola
  • Apache

Git is used to track changes for the complete zola directory, for the content but also for the asset directories (template, static, etc). The git setup is a classical client-server setup, the client is my laptop and the server is hosted in a data center somewhere on the planet.

In order to connect to the server git uses the ssh protocol and then commits the changes. For an overview about other protocols and options check out the git documentation. But git can do more.
Git offers the possibility to use hooks after or even before certain actions will be performed. Here is a short list of a few common hooks. In order to update the website after a commit was received at the server the post-receive hook from git can be used. As a basis I used this good tutorial from DigitalOcean. The idea is to place an executable script (bash, python, ...) inside the hooks folder inside the server repository which then executes certain commands. Therefore create a file called post-receive inside the hooks folder with the following content:


while read oldrev newrev ref
    if [[ $ref =~ .*/master$ ]];
        echo "Master ref received. Deploying master branch to production."
        git --work-tree=/srv/http/infides --git-dir=/srv/http/infides/.git pull
        echo "Rebuilding the site with Zola."
        zola --root /srv/http/infides build --output-dir /srv/http/infides/public
        echo "Ref $ref successfully received. Doing nothing: only the master branch will be deployed."

Make sure that the ownership and/or execution flags are set.

Zola just rebuilds the website with the new content.

Apache is used to serve the "public" folder from the command zola build. The configuration file for the virtual host looks like the following:

DocumentRoot "/srv/http/infides/public"
ErrorDocument 404 /404.html

I have omitted the other configuration directives, just the two most interesting. The ErrorDocument configuration is a really nice feature, so that my custom HTTP 404 File not found template file can be used. For more information on how to adjust custom error messages, here is the link to the Apache documentation.


So on my laptop I have a clone of the repository of the website. I create a new file, i.e. in the folder content/insights/ and check everything locally with zola serve. After everything is ready I commit this file and other assets to the server. The git hook activates itself and updates the repository on the server and zola rebuilds the website. The commands for this example are:

$ git add content/insights/
$ git commit -m "New insight"
[master c6207de] New insight
 1 file changed, 10 insertion(+)
 create mode 100644 content/insights/
$ git push

The server should respond with something like this:

Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 4 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 463 bytes | 463.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Master ref received. Deploying master branch to production.
remote: From /srv/git/infides
remote:    9acceb0..c6207de  master     -> origin/master
remote: Updating 9acceb0..c6207de
remote: Fast-forward
remote:  content/insights/ | 10 +++++++++++
remote:  1 file changed, 10 insertion(+)
remote:  create mode 100644 content/insights/
remote: Rebuilding the site with Zola.
remote: Building site...
remote: -> Creating 4 pages (0 orphan), 2 sections, and processing 17 images
remote: Done in 369ms.
   9acceb0..c6207de  master -> master


In this insight I presented how I deploy new insights onto my webserver. Most work is done by git. With the post-receive hook the repository on the server is updated and afterwards the website is rebuild with zola. As everything is already tested on a local instance with zola serve there should be no errors or failures.