Sneak Preview

Today’s Topic will be all about Continuous Integration for Hugo Deployment! Click on the link to find out more but in a nutshell, it is a pretty neat tool for hosting a static website! The thing is that now that you are done creating your website with Hugo tool in localhost. You are ready to let it run public for the whole wide world to know! After browsing tutorials after tutorials and scanning through providers, i realized that hosting providers are definitely not the way to go and to keep cost low, I have decided to use Amazon S3 Storage.

Manual Labor Sucks!

Essentially, If you do it manually, what you would do is create a bucket in S3 with the name “”. Followed by which you would proceed to run the command

// Generate Public Folder

You would then place the public folder into the bucket, if you enable static website hosting under the properties tab of the bucket, it will now provide you an endpoint for you to use to access to your website! This is all good unless you realize that you have to constantly log into the amazon cloud console and run the hugo command, empty the bucket and place the files all over again.

Follow this optional tutorial to get a domain name to be integrated with your bucket. Note that you need not follow the part where it requires the lambda functions. You would only need as the storage for the public content and as a redirect to

What we want now is to use a tool called s3cmd which seeks to helps us to configure our command line to sync content across from our local repository to our s3 bucket.

# Deploy to s3 when master gets updated.
# This expects (and does NOT check for) s3cmd to be installed and configured!
# This expects (and does NOT check for) hugo to be installed and on your $PATH


branch=$(git rev-parse --abbrev-ref HEAD)

if [[ "$branch" == "master" ]]; then
  echo "Syncing public/* with s3://$bucket/$prefix."
  s3cmd --acl-public --delete-removed --no-progress sync public/* s3://$bucket/$prefix
  echo -e "\nUpdated s3://$bucket/$prefix."
  echo "*** s3://$bucket/$prefix only syncs when master branch is updated! ***"

exit 0

Above is a sample post-commit code from git which helps to sync content to s3 bucket which is trigger by git push. Thats all folks and you have a updated website just by running the commands! git add. git commit -m “First Commit”