Build Cache for Hugo

Is there any way to enable some caching for Hugo? Basically I have a site with a few pages and it also fetches some data from remote.

As such a clean build (and currently any build) takes more than one minute (on Cloudflare). An iterative build takes about one second. Basically I think it’s just the folder resources/_gen that needs to be kept (there might be other).

This would lead to faster build times and also use less resources.

Full build:

hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended linux/amd64 BuildDate=2024-01-05T12:21:15Z VendorInfo=brew


                   | EN-AU  
-------------------+--------
  Pages            |    21  
  Paginator pages  |     0  
  Non-page files   |     0  
  Static files     |     1  
  Processed images |   413  
  Aliases          |     0  
  Sitemaps         |     1  
  Cleaned          |     0  

Total in 41434 ms

Iterative build:

Start building sites … 
hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended linux/amd64 BuildDate=2024-01-05T12:21:15Z VendorInfo=brew


                   | EN-AU  
-------------------+--------
  Pages            |    21  
  Paginator pages  |     0  
  Non-page files   |     0  
  Static files     |     1  
  Processed images |   305  
  Aliases          |     0  
  Sitemaps         |     1  
  Cleaned          |     0  

Total in 1402 ms
1 Like

Just wondering how you are doing an iterative build? Do you mean an incremental build? I didn’t think Hugo could do that?

Yes of course, basically I just don’t recalculate all images if they haven’t changed. This makes it much faster.

Understood. Sorry, I thought you had found some way to do it on CF.

Although having said that, CF is still quite quick - this is me:

13:10:00.678	hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended linux/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=gohugoio
13:10:00.679	
13:10:13.039	
13:10:13.040	                   |  EN   
13:10:13.040	-------------------+-------
13:10:13.040	  Pages            |  806  
13:10:13.040	  Paginator pages  |    0  
13:10:13.041	  Non-page files   | 3874  
13:10:13.041	  Static files     | 1604  
13:10:13.041	  Processed images |    2  
13:10:13.041	  Aliases          |    0  
13:10:13.041	  Sitemaps         |    1  
13:10:13.042	  Cleaned          |    0  
13:10:13.042	
13:10:13.043	Total in 13597 ms

but I don’t process images…

I process quite a few images and as such this of course slows it down a bit (doesn‘t really matter since Cloudflare is metered per build and not build time). I think caching would make sense, especially since Caching is available for other Frameworks.

any updates on this topic? Isn’t there any workaround to move Hugo cache into different directory that gets picked up by CF?