Featured image of post Hosting Hugo static sites on GitHub

Hosting Hugo static sites on GitHub

Github can host Jekyll sites with a simple build process as GitHub Pages. Personally I prefer Hugo.

There is also some instructions on Host on Github from Hugo but it doesn’t work well for me. Instead there seems an easier way to render static html files as GitHub Pages. So for a personal Hugo site we can do as following:

  • create a Github repo named xx.github.io (xx should be the username of your Github account); default branch is “main”
  • pull the repo locally
  • create a hugo site in the folder and download a theme
  • in config.toml add a line: publishDir = "docs"
  • write some pages and run hugo to create static site files in the “doc” folder instead of default “public”
  • run following to push
1
2
3
git add *
git commit -m "message"
git push
  • on Github, find the repo–Settings–Pages: enable GitHub Pages and set the source from /docs – Save

github-pages-setting

  • then the site is accessible via xx.github.io

To update the site we need to commit and push changes after every writing.

comments powered by Disqus
CC-BY-NC 4.0
Built with Hugo Theme Stack