Deploying with Hugo

Deploying on Hugo is a lot easier since it runs on my server too.

One of my headaches with Jeykll was the deployment. It wasn’t until I found Octopress that I had any success. Hugo wants you to use Wrecker for automated deployment. I don’t want to since I don’t host on GitHub.

Deploying (v1)

The first method I could use is a script like I have with Octopress, which runs an rsync, but instead I went with a git post-update hook:


rm -rf $PUBLIC_WWW/*
cp -r $TMP_GIT_CLONE/public/* $PUBLIC_WWW

And that copies things over nice and fast. I could do this for Jekyll as well, since now I’m version controlling my site content (in public) as well as my source code. There are downsides to this. I don’t want to sync my site folder. It’s going to get very large and messy and annoying.

The workaround for Jekyll people is to install on the server and that didn’t work for me.

Install on the Server

But Wait! There’s More!

I actually like Hugo better than Jekyll,. It feels slicker and faster and more … app like. Also since it’s not Ruby, I was able to install it properly on my server. Yes, unlike Ruby which was a crime, GoLang was incredibly easy to install on CentOS 6.

First install Go and it’s dependancies:

$ yum install golang
$ yum install hg

Now install Hugo. No you can’t yum it up:

$ export GOPATH=/usr/local/go
$ go get -v

This puts it in /usr/local/go/bin/hugo and I can run Hugo commands natively.

Which brings me to …

Deployment (v2)

Change the aforementioned script to this:


/usr/local/go/bin/hugo -s $TMP_GIT_CLONE -d $PUBLIC_WWW 

Works perfectly. Unlike Ruby which is just a brat.

Now the Magic

When I’m ready to write a new post, I can locally spin up my hugo site with hugo server, write my post, make sure it looks nice, and then commit my changes to git and push.

cd ~/Development/my-repos/hugo-site/
hugo new content/
vi content/
git add content/
git commit -m "revised some-file"
git push deploy master

And it all works.

Massive hattip to Andrew Codispiti for detailing his work which made mine easier.

%d bloggers like this: