How to setup blog with Github Pages and custom domain

Hi,

i have written a little blog about setting up a Hugo blog on Github Pages with a custom domain.
The blog is off course written with Hugo (i am starting now so bare with me), and is actually the same setup as described above.
Feel free to drop any suggestions, they are always welcome.

Thanks

Link?

funny! i was so happy that i forgot the link.
http://blog.mantziaris.eu/blog/2015/11/07/setup-a-blog-with-hugo-and-github-pages/
Sorry and thanks @RickCogley

I really liked the compactness and simpleness of your instructions, especially compared to some of the more convoluted tutorials, even here on gohugo.io. I felt a lot more like I understood what I was doing, not just typing things I didn’t really comprehend.

Having said that, it seems that all of the files went where I wanted them to on Github, but there is no html file in the root, so I got a 404 error, with both the plain github url and with a CNAME file in place.

So it seems like I have maybe one thing missing, but I’m not sure where…

Thanks for your kind words.
when creating an empty hugo site hugo new site . and executing hugo -d {path to {username}.github.io} will create at least 4 files (on my machine index.html,404.html,index.xml,sitemap.xml). is this not so in your case?

Those files are being created on my local drive, but it seems that when I run the following commands in step 5 I am pushing my source files, not the mirrored public files. Here are my local paths:

C:\Hugo\sites\mysite-source

C:\Users\Glenn\Documents\Websites\GithubPages\username.github.io

The first one is where i have been running all git commands. The second one is the one I use when I execute the hugo -d {path} command.

Should I move to the second directory before I add/commit/push?

yes. you should move to the folder where the tool generates it’s files, which is in your case C:\Users\Glenn\Documents\Websites\GithubPages\username.github.io. and then add/commit/push. Can you try?

the push failed because I’ve already pushed content from the other folder. What’s the best way to clear that out via git?

if the repository contains already you could do the following:

  • git reset --hard origin/master ( this will reset the local repository to that of the remote)
  • go into the folder and clear out everything (except the .git folder)
  • git add .
  • git commit -m “cleanout”
  • git push origin master

now the folder and the repository should be empty.
Do again step 5 and you should be ok!

I ended up doing a git push -f and that seems to have worked. The files on github now match my local files. Still dealing with some caching issues, I think, but at least I believe I have the workflow settled.

Thanks!

happy to help! added missing step in step 5!

1 Like