Improve build speeds on netlify

How can I improve the build speed on netlify?

Few thoughts

  • I’m using Hugo’s build in image processing. Original images are also included in the public build. How can I disable this?
  • All transformed images have unique hash. It seems that netlify has trouble caching the images in the build process. Is there any way to remove the unique hashing?

The following improves the build process.

  1. Including resources/gen in git
  2. building hugo local, before a commit.

This reduces the build time from 4.5 min to 1 min. This is a huge improvement.

But how can I implement this better? I am linking a cms to the website. A lot of build previews will be done. It would be fantastic to get the build time under a minute.

First of all: Netlify is typically slower on the free tier. If you are using that one then it might be connected.

Then: If you use Hugo’s image processing, then check, that Netlify’s asset optimization is disabled. You don’t need two runs of that.

I saw today for the first time that Netlify is doing some caching now on it’s own. Could be, that something changed there.

Having original images in the build is not something that slows anything down. You could remove them with a build script (hugo --gc --minify && build.sh and in build a couple of rm filename). Also, there might be a template that is using the images in original size. You might want to look into stop using the <img> tag directly in your templates and maybe create your own shortcode for images that is starting with a max-size. That should then stop the originals in your build… should = not tested but imho :wink:

Have a look at this link: https://dev.to/stereobooster/responsive-images-for-hugo-dn9

1 Like