Note that I had a blog before but I want to start from scratch
When I was attempting to blog, I started with Jekyll/Octopress. Octopress is very beautiful. It has only one con - it is slow. I searched for an alternative. There came Hugo in my hands. It is written in Go, which is for me a great alternative because I like tools written in languages that compiles to binary.
Jekyll has an option to be deployed with GitHub pages, Heroku and so on. I dislike this idea. I prefer to host it on my own (it is more fun). Unfortunately, Hugo describes how to upload the site via S/FTP. I also dislike this idea. There must be a cool way to do it, instantly. Here comes git with a great solution.
The `post-receive` hook makes the magic happen. It is simply a hook that runs after receiving a revision. It isn't even so much work to do. It is working like deployment on heroku. I host an additional repository on my webserver just for deployment.
Firstly. I create a user just for deploys since I believe it is a good practice to be a user for responsibility
# useradd -g users -m [deployer]
Next, I have created a bare git repository and create a tmp folder.
Now I need to modify the deploy repository the post-receive hook. Hooks are located in `hooks` folder. Normally, there is for everything a sample file. In my case, I hadn't it. I had to create it. My post-receive looks like this:
Now locally, I have to add a remote in git project like:
git remote add deployment deployer@host:/path/to/repository.git
Since themes in Hugo are cloned from git. It is nice to add it as a submodule.
git submodule add [link-to-theme.git] themes/[theme-name]
If I don't add this line above - the theme won't be cloned by git.
Now I can write some posts. After writing. Just commit your changes and push it wherever you want. Afterward just push to your deployment remote with:
git push deployment master
You will see also output when something is wrong or is it good