How to cache both pre-commit and Hugo

For all my repos I use pre-commit both as pre-commit linting / pre-test and as a CI step to make sure contributors keep the code style consistent and have done basic checks.
Pre-commit caches in ~/.cache/pre-commit by default.

The catch is tha the main build (of the actual sites) is done using Hugo whose cache on Netlify is stored in HUGO_CACHEDIR (which has a Netlify default).

What I am wondering is how to include both caches in my Netlify cache. At present I use the Hugo Cache Resources Plugin which takes care of the Hugo cache for me.

For a concrete example of a repo:

Netlify domain: wildtechgarden.netlify.app which is https://www.wildtechgarden.ca and is based on

and also pulls in (via Hugo modules which are a thin wrapper about Go modules)

Netlify Build Plugins, offer a built-in way to add any custom directory to Netlify cache (I think that’s what you’re after?).

Build plugin creation docs: Create Build Plugins | Netlify Docs
The specific utility you might be interested in: build/README.md at main · netlify/build · GitHub

1 Like

Thank you. I had hoped I was only missing a configuration option somewhere, but this gives me the information I need.