How to troubleshoot long build times on Netlify

I’ve got a HUGO site that takes about 4 seconds to build locally. However, the same site takes 5-10 minutes when being built with Netlify. Same is true for Cloudcannon.

Any tips on where to start troubleshooting this?


Do you process images in your site?

Yes, I do.

OK, then I’m guessing that the explanation is related to image processing.

When running locally Hugo uses the image cache, which makes it very fast.

This should work on Netlify too, in its default configuration (I have confirmed this several times lately).

But you may have some overridden configuration that breaks this. See Configure Hugo | Hugo

I’m guessing a little, but I guess you have the default file cache and the content of resources/_gen/images in your .gitignore (?)

With the above you have 2 options:

  • Commit your image cache to Git; this should then be fast everywhere.
  • I usually use something ala :cacheDir/images as the config for the image cache. Locally I have the OS env var HUGO_CACHEDIR set to some directory outside of /tmp. On Netlify, Hugo is smart and sets HUGO_CACHEDIR to Netlify’s cache dir (which survives rebuilds) if it’s not already set. I don’t know Cloudcannon good enough to say, but they should at least be happy with the first option mentioned above.

Thank you! This works like a charm!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.