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) 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:
GIT_REPO=$HOME/repositories/my-repo.git TMP_GIT_CLONE=$HOME/tmp/my-repo PUBLIC_WWW=$HOME/public_html/ git clone $GIT_REPO $TMP_GIT_CLONE rm -rf $PUBLIC_WWW/* cp -r $TMP_GIT_CLONE/public/* $PUBLIC_WWW rm -Rf $TMP_GIT_CLONE exit
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 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 github.com/spf13/hugo
This puts it in /usr/local/go/bin/hugo and I can run Hugo commands natively.
Which brings me to …
Deployment (v2) Deployment (v2)
Change the aforementioned script to this:
GIT_REPO=$HOME/repositories/my-repo.git TMP_GIT_CLONE=$HOME/tmp/my-repo PUBLIC_WWW=$HOME/public_html/ git clone $GIT_REPO $TMP_GIT_CLONE /usr/local/go/bin/hugo -s $TMP_GIT_CLONE -d $PUBLIC_WWW rm -Rf $TMP_GIT_CLONE exit
Works perfectly. Unlike Ruby which is just a brat.
Now the Magic 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/some-file.md vi content/some-file.md git add content/some-file.md 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.