How work with github pages

I make my first theme HUGO + Github.
So in my repo i have 2 branch :

  • main

And I would like to find a solution to work locally on my main branch and when everything is ok, merged to the gh-pages branch.

Then work locally on my gh-pages branch and merged it to my main branch.

But each time there is a moment where it bugs.

To work with github + hugo,
Do we only have to work on the main branch locally then merged to gh-pages ?

And never worked locally on the gh-pages branch?

How do you organize yourself?

Hello again.

Currently I do the same. My solution was to create a github workflow and configured in the settings in pages the build-branch is gh-pages


And this is my Github workflow:

name: Hugo Deploy
on: push
    runs-on: ubuntu-latest
      - name: Git checkout
        uses: actions/checkout@v2

      - name: Update theme
        # (Optional)If you have the theme added as submodule, you can pull it and use the most updated version
        run: git submodule update --init --recursive

      - name: Setup hugo
        uses: peaceiris/actions-hugo@v2
          hugo-version: "0.117.0"

      - name: Build
        # remove --minify tag if you do not need it
        # docs:
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
          personal_token: ${{ secrets.APP_TOKEN }}
          external_repository: github-username/github-repository
          # publish_dir: ./docs
          #   keep_files: true
          user_name: username
          publish_branch: gh-pages
        #   cname:

I have to test it,

after tha you put the current workflow,
What is the step ?

Only work in the main branch in local ?
And never modify the gh-pages only merge it from the local ?

Correct. Never work in branch gh-pages only in sub-branches that want to merge in the main branch and the workflow must pushed in the main-branch in .github/workflows as main.yml

And I’ve forgotten to write. You need an app_token. this you can create in Settings > Developer settings > Personal access tokens (classic)

Here you need to create a new repository token ( Generate new token (classic) )

This token you must copy and integrate in your repository.

Repository > Settings > Secrets and variables > Actions > Repository secrets

Add new and name it “APP_TOKEN” and paste your token which you have copied.

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