Automating hugo builds using CircleCI
Let someone else run your build server
- tags
- static_sites
- hugo
Contents
Here's a simple CircleCI configuration to pull down the latest version of your hugo site on GitHub commits, build it, and then push it to github pages.
Let’s set that up, following their documentation on how configure CircleCI to build static sites.
Create .circleci/config.yml
|
|
Commit and add this file to your reposity on GitHub. This runs the hugo build image. It installs git, and then checkout the repo from GitHub. We pull down any submodules if you are using that for themes. We then configure the $HUGO_BUILD_DIR
to be a worktree
of the gh-pages
branch – this is where we are going to host the files in GitHub pages. Then it runs the build itself, adds and commits those files in the gh-pages
branch back into the repository, and pushes back to GitHub
.
For this to work you need to grant CircleCI
write access to your repo which is done by setting it up with your user’s key. Lets get CircleCI working now.
- Go to CircleCI and create an account.
- Select the single linux container plan.
- Add your repository from GitHub that you want to build.
- Go to project settings, and under Permissions go to
Checkout SSH Keys
. Add User Key
to grant permission.- Remove the previous deploy key.
Now when you push your commits to GitHub
, you’ll be able to watch CircleCI build them and hopefully see your new content go up shortly!
Previously
Next