Deploying a Hugo site with Gitlab CI

As a hip, cutting edge developer, you’re using Hugo to generate your blog or website. Wordpress… pssh, you’re way too cool for that. Being cool has its complications though. How and where should you deploy your Hugo app. Should you push it locally using rsync or some other fancy means? Whatever. This simple post is going to show you how to deploy your Hugo app using Gitlab’s Continous Integration feature.

Some Features I Like About Gitlab

What is Gitlab An alternative to Github with many more features and an increasly better offering Free Private Git Repositories On of Github’s price points is to offer you a limited number of private repositories. You want more, pay more. Then Bitbucket came along and offered free private repositories, but limited the number of people you could share those repositories, it made for some weird accounting at the end of the day.

A Handy Publish Script for Static Sites Using CloudFront

#!/bin/bash CURR_COMMIT=$(git rev-parse HEAD); CURR_VERSION=$(node -e "console.log(require('./package.json').version);"); VER_HASH=$(git rev-list -n 1 v$CURR_VERSION); # Don't want to redo version bump if [ $CURR_COMMIT == $VER_HASH ] then echo 'Already up to date' exit fi npm version patch; NEW_VERSION=$(node -e "console.log(require('./package.json').version);"); echo $NEW_VERSION; git push origin head; npm run buildprod aws s3 sync ./public s3://www.example.com --size-only --delete; # Invalidate cache aws cloudfront create-invalidation \ --distribution-id YOUR_DISTRIBUTION_ID \ --paths "/*"; What Does It Do?

Preventing unwanted git email leaking

Maybe you work on different git projects, on business, then at home for personal projects. In the past, as a convenience, I set my ~/.gitconfig to include my name and email like the following. [user] name = "Shane A. Stillwell" email = "shanestillwell+spam@gmail.com" This is exactly what git wants you to do when it detects you haven’t set your name or email *** Please tell me who you are.

Ignoring Files and Folders in Git

Just a hint, it’s a lot easier than Subversion. My love for Subversion grows colder each day. In your repository root directory you’ll want to create a file called .gitignore. In that file you’ll want to specify files and folders to ignore. For example. Ignore the entire Magento /media folder. media/**/* The root repository .gitignore file will act as a global but can be overridden in subdirecties by creating a .