Hugo build caching

Is there a way to get build caching in Hugo sites? (cc @Dario , who seems to be the resident build cache maven)
19 Replies
Dario
Darioβ€’5mo ago
Yes, I can impelement that πŸ™‚ Since I need to do it for docusaurus I might as well just do it for Hugo too πŸ™‚ but I have zero Hugo knowledge I'd like to get someone from the Hugo team ideally confirm what directories need to be cached are you by any chance a Hugo maintainer and/or can you connect me with one? πŸ˜…
tmcltr
tmcltrβ€’5mo ago
Oh fantastic! I am not a maintainer but I can reach out to one to let them know you're interested in working on this.
tmcltr
tmcltrβ€’5mo ago
the cacheDir is configurable. I think that's all you'd need to support: https://gohugo.io/getting-started/configuration/#configure-cachedir
Configure Hugo
How to configure your Hugo site.
tmcltr
tmcltrβ€’5mo ago
Thank you very much for looking into this!
jmooring
jmooringβ€’5mo ago
By default, we create a "hugo_cache" directory in the user cache directory as determined by https://pkg.go.dev/os#UserCacheDir. For example, by default, on Linux my cache directory is /home/jmooring/.cache/hugo_cache. Although users can override the location of the cache directory, that's not something you need to worry about... it would be a self inflicted wound in this context.
jmooring
jmooringβ€’5mo ago
By default, this directory contains cached modules and remote data. Users can configure a site to cache images in this location as well. This is a big win for sites that perform image processing. See https://gohugo.io/getting-started/configuration/#configure-file-caches.
Configure Hugo
How to configure your Hugo site.
tmcltr
tmcltrβ€’5mo ago
Dario, @jmooring is on the Hugo team and would be an excellent resource if you have any questions! Thanks again, both of you!
Dario
Darioβ€’5mo ago
I'm sorry I completely missed the replies is thread! πŸ˜“ (I feel like discord's notifications aren't always the most helpful! πŸ˜…) our build cache implementation is unfortunately a bit limited and it doesn't really implements any integration with possible framework customization, so it always only checks the default directory (/directories) fortunately it seems like you're ok with that πŸ™‚πŸ‘
Dario
Darioβ€’5mo ago
https://github.com/gohugoio/hugo/blob/7f3061723e3df064515fc57c183b06ed16f26b75/helpers/path.go#L374 regarding the netlify=true... I need to check I am not 100% sure if that applies to the v2 build image πŸ€”
GitHub
hugo/helpers/path.go at 7f3061723e3df064515fc57c183b06ed16f26b75 Β· ...
The world’s fastest framework for building websites. - gohugoio/hugo
Dario
Darioβ€’5mo ago
I'll have to check about the dir location... as I said it's just static/hardcoded on our end, so I am not 100% sure if UserCacheDir will always be the same for every single build... if it's not this could require a bit of refactoring on our end (with some potential pushbacks). Or maybe you'd be willing to add an additional ad-hoc if check for Cloudflare like you did here: https://github.com/gohugoio/hugo/blob/7f3061723e3df064515fc57c183b06ed16f26b75/helpers/path.go#L373-L381
GitHub
hugo/helpers/path.go at 7f3061723e3df064515fc57c183b06ed16f26b75 Β· ...
The world’s fastest framework for building websites. - gohugoio/hugo
Dario
Darioβ€’5mo ago
@jmooring (or @tmcltr) could you let me know the simplest/dumbest way in which I can check if the caching is taking place? does hugo provide logs in its build command? and does the caching always kicks in? sorry before I forget, thanks for connecting us! ❀️
jmooring
jmooringβ€’5mo ago
@Dario I'm not receiving email notifications, so feel free to reach me via email [email protected]. "Or maybe you'd be willing to add an additional ad-hoc if check" -- yes, I think that would be fine. "netlify=true" I hope that's not true anymore.
0x107d
0x107dβ€’5mo ago
Would that cover resized images as well? (I'm not committing resources/_gen to the repo)
tmcltr
tmcltrβ€’2mo ago
Does anyone have a status update on this? @Dario @jmooring
Dario
Darioβ€’2mo ago
Hey @tmcltr so sorry this completely went off my radar πŸ˜“ I did start look into it but there's a non trivial issue with enabling build caching with Hugo πŸ˜“ the fact that hugo is not node/npm based and all our build caching code is npm-based, so to support hugo we'd have to add a separate build cache implementation from scratch for it πŸ˜• not impossible but it'd take some effort for sure (and I don't really have lots of time at the moment, I can make a note of this and get back to it as soon as I can if it can help πŸ˜“, or I can ping the team which own that infrastructure but I can't imagine this getting prioritized unfortunately πŸ˜“)
tmcltr
tmcltrβ€’2mo ago
Ah ok, understood! Thanks for looking into it anyway.
tmcltr
tmcltrβ€’2mo ago
I was hoping there'd be at least some appetite to make this happen, since y'all appear to be using Hugo and Pages for the your own developer docs: https://blog.cloudflare.com/new-dev-docs/
The Cloudflare Blog
We rebuilt Cloudflare's developer documentation - here's what we le...
In this blog post, we’ll cover the history of Cloudflare’s developer docs, why we made this recent transition, and why we continue to dogfood Cloudflare’s products as we develop applications internally.
tmcltr
tmcltrβ€’2mo ago
Looks like @Kristian worked on that post, so maybe he knows if that's still the case?
Want results from more Discord servers?
Add your server