Hosting on Github: Why github actions needed?

I have set up many Hugo sites on GitHub, but only the “Project page” type and only generated with GitHub actions.

  1. Create the site.
  2. Add a “.github/workflows/gh-pages.yml” as mentioned in the docs.
  3. Add a “static/CNAME” file with the domain the site is going to use.
  4. Push the code to a GitHub repo.
  5. In the repo settings in the “Pages” section tell GitHub to serve pages from the root of the “gh-pages” branch (the action script will build and push that for you).
  6. Add a CNAME record pointing to “<USERNAME|ORGANIZATION>.github.io.” in the DNS.

Now the site will deploy on each new push to the “main” branch.

Quick and easy!

I do this while on a call with the customer. Then I help them set up a Forestry.io account and they can start add content to their new site before the call is over.

You can create the “gh-pages” branch with the generated content manually but that is a hassel. So mush easier to have GitHub action do it for you.

If you really want to generate the pages locally I would pick “docs” folder in “main” branch as the options in GitHub repo → Settings → “Pages”. Then you specify that Hugo should build the site in “docs” instead of “public”. I believe that should work but I have never tested it.

(The “User/Organisation” type pages seems only relevant if you plan to use https://<USERNAME|ORGANIZATION>.github.io/ as the actual address of the site.)

2 Likes