Skip to main content

This blog now runs under Hugo

So I wanted to give another chance to Hugo, I was using Jekyll for a while but I didn’t quite like the hassle of managing ruby dependencies and versions.

At the same time, I also took the opportunity to entirely redo the layout of the page, using the Anubis theme as a base. I liked that the old design was quite minimal and i wanted to preserve that. I also tried to avoid using JavaScript so if you block it, it will look exactly the same, on any device 😁.

Also migrating the posts from one platform to another worked flawlessly with almost no modification to the source files 👍.

Now I use two repositories for managing this page, one repo for serving the static build, and other repo for making the edits.

Using a workflow is very convenient with this setup becase you can write posts from everywhere without having a local enviroment to deploy.

Setting up the environment

If you want to make a similar setup, here’s the steps to reproduce it:

  • Create the user.github.io repo, here is where you will deploy the final statified webpage.

  • Create another repo myblog-hugo, here is where you will edit the page.

  • Create a new personal access token and copy the code generated!: https://github.com/settings/tokens/new

    Note that maybe you have to check the repo checkbox while generating the token, so push access from one repo to another is allowed.

  • Go to both repositories > section Secrets and add a new Secret pasting the code generated. Name it as you like (e.g hugosecret).

  • In your myblog-hugo repo, create the following file at .github/workflows/main.yml with this content, changing the <user> variable to your liking.

name: hugo build

on:
  push:
    branches:
    - master

jobs:
  build-deploy:
  
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v3

    - name: Setup Hugo
      uses: peaceiris/actions-hugo@v2
      with:
        hugo-version: '0.96.0'

    - name: Build
      run: hugo --minify

    - name: Deploy
      uses: peaceiris/actions-gh-pages@v2
      env:
        PERSONAL_TOKEN: ${{ secrets.HUGOSECRET }}
        EXTERNAL_REPOSITORY: <user>/<user>.github.io
        PUBLISH_BRANCH: master
        PUBLISH_DIR: ./public/