Introduction

The following is a small tutorial on how to build a static webpage using Zola and Sourcehut's build service.

This guide is kindof redundant since Zola's documentatioin is already very clear, but I want to write a first post in order to test this site.


Prerequisites

First off, download Zola using your package manager. Installation instructions can be found on their site.

After that, create an account on Sourcehut. I paid for the "Amateur Hackers" tier as I'm just getting started with this project.


Creating a static webpage

All commands assume you are on the root of your project.


Zola

Once you've downloaded Zola, create an empty dir, initialize you site and initialize a git repo:

$ mkdir www && cd www
$ zola init posixlycorrect.com
$ git init

Test everything is fine:

$ zola serve

If it is, download a theme:

$ mkdir -p themes
$ cd themes
$ git clone https://github.com/pawroman/zola-theme-terminimal.git

Add content to your site:

$ mkdir -p content
$ cd content
$ nvim _index.md    ## add to this whatever your theme needs in order to work
                    ## usually this is detailed on the theme's docs

$ nvim blog.mb      ## landing page for posixlycorrect.com/blog
$ mkdir blog && cd blog
$ nvim building_a_site_with_zola_and_sourcehut.md   ## your first post
$ cd ..
$ nvim about.md    ## your about page

Check that everything looks good:

$ zola serve

Sourcehut

Your site is now ready to be published! In order to do that, commit your changes and add a remote repo from sourcehut:

$ git add .
$ git commit
$ git remote add origin git@git.sr.ht:~fabianmv/posixlycorrect.com

Add a build manifest so sourcehut knows how to publish your site:

$ nvim .build.yml

My manifest looks like this:

image: alpine/edge
packages:
  - hut
  - zola
oauth: pages.sr.ht/PAGES:RW
environment:
  site: posixlycorrect.com
sources:
  - https://git.sr.ht/~fabianmv/posixlycorrect.com
tasks:
  - build: |
      cd posixlycorrect.com
      mkdir -p templates
      zola build
  - package: |
      cd posixlycorrect.com
      tar -C public -cvz . > ../site.tar.gz
  - upload: |
      hut pages publish -d $site site.tar.gz

Add and commit your changes and push your repo:

$ git add .
$ git commit
$ git push

Your website now should be visible! Updating it is a matter of making changes and pushing to your repo.

Good luck!

If you have any questions, feel free to email me.



Good luck!

If you have any questions, feel free to email me.