#blog

My First Post, Continued

Continuing from my last post…

Pink clouds in a sunset sky

I was wrong in my last post. I thought my blog setup was complete, but it actually wasn't. I missed one more step: deploying to GitHub.

Although I had pushed my blog to GitHub, the page just wouldn't load. It kept showing me an Error 404 page, and I thought it was due to my custom domain settings.

Then I found out that I had to use a GitHub Action to get my blog up and running. Reference: Hosting on GitHub.

  1. First, create a file at .github/workflows/gh-pages.yml with the following content:
    name: github pages
    
    on:
      push:
        branches:
          - main  # Set a branch to deploy
    
    jobs:
      deploy:
        runs-on: ubuntu-18.04
        steps:
          - uses: actions/checkout@v2
            with:
              submodules: true  # Fetch Hugo themes (true OR recursive)
              fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod
    
          - name: Setup Hugo
            uses: peaceiris/actions-hugo@v2
            with:
              hugo-version: 'latest'
              # extended: true
    
          - name: Build
            run: hugo --minify
    
          - name: Deploy
            uses: peaceiris/actions-gh-pages@v3
            with:
              github_token: ${{ secrets.GITHUB_TOKEN }}
              publish_dir: ./public

    There is also documentation for a more advanced setup.

Note: the workflow above is from 2021. The action versions and the ubuntu-18.04 runner are now outdated, so check the current Hugo docs before copying it.