Problem with deploying Hugo site to GitHub Pages, 404 after deployment

Hello everyone,

I am working on a Hugo site that runs perfectly locally with a the theme ananke (no complex configurations). I’m trying to deploy this site to GitHub Pages using a GitHub Actions workflow, but I am encountering an issue: the action runs successfully without errors, but when I visit my site’s URL on GitHub Pages, I get a 404 error.

Problem Details:

What I have tried:

  • I have verified that GitHub Pages is configured correctly in the repository settings.
  • My .yml workflow file looks correct, but here is the content for reference:
''' 
name: Deploy to GitHub Pages

on:
  push:
    branches:
      - main  # ou 'main' si ta branche principale s'appelle 'main'

permissions:
  contents: write  # Autorise à pousser dans le repo

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.145.0'
          extended: true

      - name: Build the site
        run: hugo --minify

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.MY_GITHUB_TOKEN }}  # Utilise le Personal Access Token que tu as ajouté comme secret
          publish_dir: ./public
          publish_branch: gh-pages  # Cette ligne est ajoutée pour spécifier la branche de déploiement
          force_orphan: true
'''

Question:

  • Do you have any idea what could be causing this 404?
  • Is there something missing in the GitHub Pages configuration or the GitHub Actions workflow?

Thank you in advance for your help!

Use the recommended workflow… works great.

https://gohugo.io/host-and-deploy/host-on-github-pages/