I just created the website using hugo and github pages, but ultimately when applied theme, getting 404 errorr.
Website Link: https://github.com/needforcode/needforcode.github.io
Things I have done:
- I am using user pages of github.
- changed base url in config.toml folder to https://needforcode.github.io
- used mainroad hugo theme, added it as submodule during generation.
- Changed output directory from publish to docs and configured the same in config.toml using publishDir key.
- able to see the website in localhost:1313, but when i pushed to github master, not able to see and site and ended up with 404.
Appreciate your help. Thanks in advance.
You need to commit the hugo generated HTML files for that to work. It doesn’t auto-run hugo behind the scenes (how would it know which static site generator, which version, etc. to run?).
Look into publishing GitHub Pages using Travis CI. Or better yet, if you don’t really care about the .github.io domain, look into Netlify.
Thanks for the reply.
If I understand correctly, the hugo generated html files will be in docs directory which is a publishDir directory configured in config.toml file, and the index.html is in the project root directory and I commited all of them to git.
Here is the link i committed to github.
So will the git not be able to pull the html and display. Do i need to use netlify or Travis CI for a theme to work ?
Please correct me if i am wrong !!
You are mixing the Github Pages’ publishing from docs vs publishing from foo.github.io. You just need to read the docs: Configuring a publishing source for your GitHub Pages site - GitHub Docs.
As you have not read those docs yet, I’d suggest that you navigate to netlify.com and read how to set up Hugo site publishing using that instead. The Netlify customer service is great too (Might sound like it but I am not at all affiliated with Netlify :P).
Thanks for pointing out the link. Deployed using traditional github docs approach itself without travis/netlify and it worked. Thanks again.
After you have run the command “hugo” in the CMD and you’re able to see it on localhost:1313 to then use it as a github pages you need to use the generated files, which is simply your “public” folder in the project.
This post is 2 years old and has been marked solved. Please do not resurrect old posts.