Deploying to Github pages

Okay well geez, I was able to do it with a local repo.
The deployment steps are not very easy to understand for a first time Hugo user and might help with some github action to do everything through it instead of going through countless tries.

Here’s what I did in case if someone stumbles like me and doesn’t find anser even from many such similar posts here to try this one out too.

  1. Create your standard hugo site as mentioned in the hugo docs.

  2. Once created run hugo to build your site and hugo server afterwards to verify that everything is sailing smoothly.

  3. create a folder named hugo site and run git init which will initialize a empty git repo to your local device. No need to create a github repo just to host these files although if it is suggested in the docs you can do that too but not necessary I guess.

  4. Copy the created site to the folder we just created in step 3 except the public folder(we’ll do that again).

  5. Now you are in your main site with all the hugo files as well as your site. It’s time to deploy.

  6. Create a github repo now that will host just the site and not hugo files with whatever site name you want, you can refer github pages document for more info.

  7. git submodule add -b master https://github.com/<USERNAME>/<USERNAME>.github.io.git public run this command using the info from repo the above you created. This will add an empty public folder in the directory you are working in.

  8. Create the deploy.sh file as mentioned in the hugo docs, you can run sudo gedit deploy.sh and save the contents from docs in it and then run it. link to deploy.sh

  9. You site is now ready to view at https://github.com/<USERNAME>/<USERNAME>.github.io s site page on master branch itself.

Hope this helps.