Using Hugo and Continuous Integration to easily build a Static Website
Rachael Worthington is working on getting her blog set up as a static site built by Hugo, a new entry to the static-site generator field written in Go. She’s having a few issues so I thought I’d write about a recent site I set up with Hugo and how that site is getting built/deployed.
I recently set up a static website for my father at
I looked into several continuous integration services: TravisCI, CircleCI, and Codeship, because I wanted to get the site built and deployed whenever I pushed code into Bitbucket.
TravisCI is popular among the open-source set because they have a free plan for open source projects, the next plan up is $129/mo and that’s just not worth it for a couple of sites. CircleCI looked good but does not appear to support builds for Go-based projects.
Codeship supports Go, and I found this article about deploying a Hugo site using the service: Hugo Deployment via Codeship. My setup for
I connected Codeship to my Bitbucket account, and crated a new project for the repo. I created two build pipelines (described in the article above, I won’t re-iterate here) - one builds off of the master
branch and deploys to the main site. The other build pipeline builds from a feature branch (feature/responsive
, for a responsive update to the site) and deploys to a subdirectory of the main URL.
My main build pipeline uses a “Custom Script” build with the following script:
# get hugo
go get -v github.com/spf13/hugo
# build
hugo --verbose
# deploy via ftp
lftp -c "open -u $FTP_USERNAME,$FTP_PASSWORD $SERVER; set ssl:verify-certificate no; mirror -R ${HOME}/clone/_site ."
So, yeah…. FTP. The site is hosted on a cheap GoDaddy account that I don’t run, so there you go.
Hope this helps out, Rachael, and good luck on your blog!