Hosting Zola Project on Github Pages

2022-10-03


https://aditeya.github.io/cables on network switch

Photo By Lars Kienle on Unsplash

Zola is a static site generator, built in rust. Infact, this site is built using Zola. It has the advantage of separating content from html, css and js, which makes development much easier.

This post won't go into the details of creating a site using zola, but it'll detail how you can host your zola site on Github Pages. The idea is you'll create a repo with the <account_name>.github.io and push your zola build files onto it.

Once thats done you'll add a custom Github Action Workflow:

  1. Go to the actions tab of your repo
  2. Click on the New workflow button
  3. add the following yaml file and commit (feel free to change name on the first line)
# main.yml
name: adi blog on GitHub Pages

on: 
 push:
  branches:
   - main

jobs:
  build:
    name: Publish site
    runs-on: ubuntu-latest
    steps:
    - name: Checkout main
      uses: actions/checkout@v3.0.0
    - name: Build and deploy
      uses: shalzz/zola-deploy-action@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Lastly, you'll have to point the deploy work flow to the correct branch. The release build gets saved to the gh-pages branch. Just go to Settings > Pages and select gh-pages in the branch section. After you select the correct branch, the deploy action will run again. You can then check your repo name or <account_name>.github.io to see the final product.