Since my blog source code is private, this blog post contains snippets of how I set up Travis CI to build and push Hugo’s public folder to another repository that hosts my public Github Pages.

It’s a simple solution, yet the top Google results only feature custom scripts 🤷🤷‍♀️🤷‍♂️.

Configuring Travis CI #


  - curl -LO
  - sudo dpkg -i hugo_0.59.1_Linux-64bit.deb

  - git submodule init
  - git submodule update
  - hugo
  - rm -Rf .git
  - git clone $REMOTE_REPO remote_repo
  - cp -TR public remote_repo
  - cd remote_repo
  - git add .
  - git commit -m "🚀 CI Updating blog 🎁"
  - git push
  • Line 10 removes the existing .git folder in order to clone another git folder inside it and push that one instead
  • Line 12 clones an existing git repository into a folder called remote_repo
  • Line 13 copies all the content from public into remote_repo

On line 12, the REMOTE_REPO is configured as a secure Travis environment variable. It contains the a link to a remote repository in the format of<user>/<repo>

The personal Github token is configured to have access to public_repo. Update line 3 as needed if you’re using a newer Hugo release.