Host Hugo on github pages

This is my first post. I used hugo to make this blog. I totally recommend it. It’s really quick to create a blog without the need to install anything extra(no plugins etc).

It took me some time to figure out how to host the blog on github pages. I was struggling to deploy the hugo generated static website in github via /docs folder on master branch. It didn’t work. Apparently it does not work having docs folder and hugo code on the same branch. The docs folder needs to be in a repo that it does not have name username.github.io. Then I decided to separate the hugo code and generated output in two different repositories. I decided to follow the approach of hosting Personal/Organization Pages from Hugo website.

How to host hugo pages on github pages using windows os:

    1. Create a repo with the name username.github.io for the hugo content.
    1. Create a repo with the name username.github.io-hugo for the generated static website.
    1. Build by using : hugo in the cmd. Since the theme is defined in config.toml, there is no need to use the argument -t theme.
    1. Delete the public folder that was created.
    1. “git submodule add -b master https://github.com/username/username.github.io.git public”. this line allows you to keep username.github.io repository in a subdirectory of username.github.io-hugo.
    1. add a deploy.sh and copy the content from Hugo website. IMPORTANT change hugo to ./hugo in order the script to work.
    1. add and commit all the related files to hugo and push them to username.github.io-hugo
    1. open cmd and use “icacls deploy.sh /reset” in order to remove any permission on this script. Or use [cmder] (http://cmder.net/) and execute the command : “chmod +x deploy.sh”.
    1. deploy.sh “Your optional commit message” Note: you need to have bash installed. I am using git bash which was installed together with git.

ENDING NOTES

public class Application
{
	static void Main(string[] args)
	{
		Console.WriteLine("I posted my first post. yay !!");
	}
}