Github Pages: issue working with public folder

Hi, I have created a Github Pages site with Hugo (theme Gokarna), but CSS does not seem to work: the dark/light mode is not available.

Steps

  1. Create Github repo,
  2. Locally run “hugo”. This creates a ‘public’ folder,
  3. Push ‘public’ folder to Github Pages, as explained in Hugo basic usage documentation:

" In a simple hosting environment, where you typically ftp, rsync, or scp your files to the root of a virtual host, the contents of the public directory are all that you need."

The Gokarna example website has a CSS with a dark/light theme that can be set at the top right. My website does not show that option. Locally my website does show a dark/light theme.

Gokarna example website: https://gokarna-hugo.netlify.app/
My public folder on Github: GitHub - peterkorteweg/peterkorteweg.github.io: Files for Github Pages.

Can you explain why is a copy of the local ‘public’ folder not working as expected?

You have an active jekyll build action. This builds your site an publishes it. But not from your sites root.

Looks like you have to reconfiger your github pages deployment setting. Have a look at this answer.

Thanks for the help. I use the option “Deploy from a branch” on Github. But indeed I can see that this option triggers an action to build with Jekyll. I will read the documentation on Github Pages to see how I can turn off a Jekyll build.

Sometimes you will have to unpublish your site and then reenable publish to make it working.

Either from branch or using the static html action as described in the linked answer

https://gohugo.io/hosting-and-deployment/hosting-on-github/

This workflow is used by thousands of sites.

Thank you @irkode and @jmooring for your help. I decided to use the workflow for hosting on Github. This means I had to push my “raw” website content to Github and run Hugo via the workflow from @jmooring.

I was under the impression that I could also run a static workflow on the “public” folder on Github, but as described above that did not work with the Gokarna theme.

1 Like

With this workflow there’s no need to check the public directory into source control.

Add public/ to your .gitignore file then:

git rm -rf public
git add -A
git commit -m "Remove publid directory from source control"
git push
1 Like

Just for clarification:

You can use the content of a hugo build using Github actionsStatic HTML.

But I’m with @jmooring. The workflow is easy to setup, easy to operate and stable. And you don’t have to separate source and publish. Just push sources and you’re done.

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