Help with Github Pages setup

I’m following the docs (Host on GitHub | Hugo) and using the Github Action (Hugo setup · Actions · GitHub Marketplace · GitHub), however I’m missing a piece.

Github Pages is asking for a build folder of /docs to publish the site. But if I supply that, then the site is built from there and the Github Action of running the hugo -b https://mydomain.com/ build command is not used.

If I don’t supply a /docs folder in my repository, then Github Pages errors out saying a docs folder is missing.

What am I missing here?

Here’s my gh-pages.yml file:

name: github pages

on:
  push:
    branches:
      - master  # 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.4.13
        with:
          hugo-version: 'latest'
          extended: true

      - name: Build
        run: hugo -b https://myusername.github.io/sitename

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./docs

and in my config.toml I have:

baseURL = "/"
publishDir = "docs"

When the site is published, it is publishing directly from /docs without using the newly built site from the Github Action.

So I finally figured out that the Github Pages action will push the static site from master/main branch /docs folder, and commit that to the gh-pages branch. This is where Github Pages serves the site.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.