@latest_post
How to set up automatic Hugo website generation and deployment with Git
Let's say that you have tried Hugo, you liked it, and made
a website with it.
Now you are ready to deploy that website for the whole world to see.
Wouldn't it be great if you could just do:
git add .
git commit -m "Updated blog content"
git push
And be done with it?
Well, if that sounds like your kind of thing; something you'd like to have...
Then read on my friend!
Inventory
What do you need for this tutorial?
- A public server somewhere. If you don't have one, you can get a VPS (Virtual Private Server) from Linode , DigitalOcean or similar providers.
- An account with access to
sudo. - You have
gitavailable, from this guide. - You use Gitolite to manage your repositories, from this guide.
- A configured webserver ---I recommend looking into NGINX , since it's super easy to setup in Ubuntu.
Let's assume:
-
A local
~/.ssh/configfile with this content:~/.ssh/config Host git-server# This is the IP for your VPSHostName 111.111.111.111Port 22# This is the remote userUser yoloHost web-server# This is the IP for your other VPSHostName 222.222.222.222Port 22# This is the remote userUser webcustomer -
You have your Hugo project versioned with git and you can push code to the remote repository.
-
The repository's name is
yolo-web, so you can clone it like this:git clone git@git-server:yolo-web