Hugo to Netlify 6 second build?

First of all, thank you to everyone who has worked on Hugo over the years, even as a newcomer it has been a joy to use.

I’m not sure if this belongs in the Netlify forums instead, but I figured I’d ask here first. I built a site with Hugo that deploys to Netlify via Github. It normally takes about 30 seconds to deploy the site. Obviously, a static site is not going to deploy instantly, but I knew the build time was partly because I had some npm in the project and other dependencies, so I wanted to see how fast a barebones Hugo site could deploy with no dependencies or bloat.

I created a new Hugo site, and added enough html and content to say Hello World. I pushed it to Netlify, then redeployed a few times to see how long the builds took with a cache. It took around 12-14 seconds each time.

2:39:45 PM: build-image version: 900a223ea0f4a600c43255115089305a2b808649 (focal)
2:39:45 PM: buildbot version: ef13074d2cce7f50f6d57a698cb1897c8a6f2a51
2:39:45 PM: Fetching cached dependencies
2:39:45 PM: Starting to download cache of 61.1MB
2:39:46 PM: Finished downloading cache in 438ms
2:39:46 PM: Starting to extract cache
2:39:46 PM: Finished extracting cache in 337ms
2:39:46 PM: Finished fetching cache in 838ms
2:39:46 PM: Starting to prepare the repo for build
2:39:46 PM: Preparing Git Reference refs/heads/master
2:39:46 PM: Parsing package.json dependencies
2:39:47 PM: Starting to install dependencies
2:39:47 PM: Python version set to 3.8
2:39:47 PM: Attempting Ruby version 2.7.2, read from environment
2:39:48 PM: Using Ruby version 2.7.2
2:39:48 PM: Started restoring cached go cache
2:39:48 PM: Finished restoring cached go cache
2:39:48 PM: Installing Go version 1.19.5 (requested 1.19.5)
2:39:54 PM: go version go1.19.5 linux/amd64
2:39:54 PM: Using PHP version 8.0
2:39:55 PM: Started restoring cached Node.js version
2:39:56 PM: Finished restoring cached Node.js version
2:39:56 PM: v16.20.0 is already installed.
2:39:56 PM: Now using node v16.20.0 (npm v8.19.4)
2:39:56 PM: Enabling Node.js Corepack
2:39:56 PM: Started restoring cached build plugins
2:39:56 PM: Finished restoring cached build plugins
2:39:56 PM: Install dependencies script success
2:39:56 PM: Starting build script
2:39:57 PM: Detected 2 framework(s)
2:39:57 PM: "hugo" at version "unknown"
2:39:57 PM: "zola" at version "unknown"
2:39:57 PM: Section completed: initializing

Right after it says “initializing”, the Netlify Build process starts and the site is live 1 second later. Obviously, Hugo is not the bottleneck here.

While 13 seconds is reasonably fast, it seems 12 of those seconds are spent verifying dependencies. Ruby, Python, PHP, Go, Node.js, I don’t recall having half of these installed on my PC, does Hugo need all this stuff or is it just part of the Netlify process regardless of the build command?

In doing a bit of research, I found an old Netlify blog from 2015 saying they can deploy a Hugo site in just 6 seconds.

Hosting Hugo on Netlify–Insanely Fast Deploys

Was it because they were using an older, simpler version of Hugo back in 2015, or has Netlify itself changed somehow?

I’ve poked around forums and blog posts for a while, and I can’t figure out how deployment time has more than doubled since that blog post was written. Is it still possible in 2023 for a Hugo site to have a sub 10 second deploy? If not, what has changed? What secret sauce were they using eight years ago to get such quick builds?

For a site of medium complexity with very few images, on the second Netlify build (the cache is already warm):

Step Time (seconds)
Initialize 14
Build 10
Deploy 1
Cleanup 4
Post processing 2

I am quite satisfied with the total time of 31 seconds.

Note that the build time also includes:

  • Download of Embedded Dart Sass
  • Download of the Pagefind search indexer
  • Running the Pagefind indexer
  • A script to capture some Git information from everything in the assets directory
  • Autoprefixing (resources.PostCSS)
  • CSS purging (resources.PostProcess)[1]

Also note that the total time varies by time of day, presumably based on resource availability.

  1. CSS purging takes a while, and should be reserved for production builds (don’t do it when running hugo server). ↩︎