Netlify's Awesome Build Process
September 13, 2017
[ Development ]
netlify git hugo

In the past few posts, I have discussed how I have moved all of my static websites from AWS S3/Cloudfront to Netlify. There are two ways to build a Hugo (or other static website generator) website on Netlify:

Whereas the second option is awesome, I chose the first option because I had to do some post-processing of the generated raw html files before uploading the files.

However, since the release of Hugo 0.27 a couple days ago, a bug was fixed that no longer required me to post-process the html files.1 This means I can now let Netlify build my site. This is great, because I can update the site from anywhere now, without having Hugo installed. I can simply upload a new markdown post to my Github repository and Netlify will autodeploy it! Sweet!

Here is the process for doing this, assuming you already have a Hugo website you can generate locally.

Step 1: Prepare your Hugo website

Normally, when you build a Hugo website, you might go to your themes directory, and git clone a theme from a Github repository. If you do this, you will need to do one of the following:

git submodule add themes/milano
git submodule init
git submodule update

And when you need to get theme updates in the future:

git submodule update --remote themes/milano
git init
git add .
git commit -m "first commit"
git remote add origin
git push -u origin master

When you make changes in the future, simply use the git add/commit/push process to upload to your Github repository.

Step 3: Create a Site on Netlify

As mentioned in my previous post on Netlify, there are a lot of advantages that Netlify has over S3/Cloudfront. Besides being easier to setup, it also automatically invalidates the CDN files when necessary. Normally, a CDN caches files and checks for changes periodically, which means site updates can take a day or so to become live. However, Netlify automatically invalidates these files forcing the CDN to get new changes from the source everytime it deploys a new version. With AWS Cloudfront, you would need to send an invalidation command from the commandline (or from their Web UI).

I highly recommend Netlify for your static websites. It is an awesome resource!

  1. Actually, I was the one that made the pull request and submitted the bug-fix. Thanks to the Hugo team for accepting my pull request!
  • 2017/09/08 Ditching AWS
  • 2017/09/05 Static Website Hosting - From AWS to Netlify!
  • 2017/08/28 Introducing Milano Hugo Theme
  • 2017/08/25 Milano Has 297 Lines of Code
  • 2017/08/22 Fork, Branch, and Pull - A Concise Git Workflow
  • Comments

    comments powered by Disqus