Github Pages with Hugo
Table of Contents #
Introduction #
I had a bit of difficulty setting up Hugo to work with Github Pages, so I decided to document how I was able to make it work.
Getting Started #
This guide assumes you already have a Hugo site. If you do not, you can learn how to here.
You will also need a Github Pages repo setup, these are pretty simple, and you can use this guide.
Both of these are pretty simple to setup, but if you have any questions, ask Google first, but if that doesn’t work, leave me an email
Prepare your environment #
After you’ve created your site repo, delete the contents. Once that’s done, head to wherever you wish to keep it on your local machine and clone it.
Once you’re done, cd
to it and create an empty file named .nojekyll
touch .nojekyll
After that, go ahead and generate your site with Hugo. If you’ve already made your site and want to migrate to Github Pages, just copy the contents over to the new repo.
Now, we’ll need to edit the config.toml
to configure the site to be compatible with Github Pages.
vim config.toml
Add the following line, under the top set of variables
publishDir = "docs"
Go to your Repo>Settings>Github Pages> and set Source
directory to /docs
Building your site #
Go to the folder where you have your site and run hugo
.
Now that your site has been built, add all, commit, and push to Github.