Automate Hugo Deployment to GitHub Page

Setting up a blog under your own control might sound tricky, unless you know the secret … Mine is Hugo + GitHub Pages.

There are lots of helpful articles available online, a proof that many people have tried it out.

Below is a summary of my approach:

  1. Set up a repository for the source content.

  2. Set up another repository for the GitHub page, which will host your generated website.

    For these first two steps, you can aslo follow Build a Personal Website With Github Pages and Hugo.

  3. Automate the deployment using GitHub Actions.

    Create a yaml file in your GitHub folder workflows (my workflow is here).

    The most important job is, surprise, surprise, named Deployment.

    - name: Deploy
      uses: peaceiris/actions-gh-pages@v3.8.0
      with:
        personal_token: ${{ secrets.PERSONAL_TOKEN }}
        external_repository: azure562/azure562.github.io # Replace with your own GitHub Page repo
        publish_branch: master
        publish_dir: ./public
    

Note the following:

If you are reading this as a blog post, then it means it works! 🎉