Have project use commited `resources` from a theme/module

Still in the context of Consider using Hugo Pipes for the CSS and adding functionality for custom CSS overrides · Issue #379 · theNewDynamic/gohugo-theme-ananke · GitHub I’m trying to make sure users don’t need npm/postcss unless they want to customize the style.

For any given project, I know Hugo will look for the asset in the resources directory if PostCSS is not installed. But it seems to resources dir is not part of Hugo’s unison file system. So it has to live on the project level.

Before I dig into working a theme setting and logic to allow users to choose from preprocessed or “process yourself” asset, has anyone found a workaround for resources committed to the theme to be available to the project?


Unfortunately that is not possible from what I know.

This question has come up before, over here and here, in a slightly different form about calling generated images, after Image Processing Methods.

So I cannot think of a way that you could add logic to call generated CSS or JS resources from the templates with existing methods.

Perhaps we could make a request for a new method to check whether a Resource is already generated and present in Hugo’s Cache.

Something like resource.Cached would make possible conditions like:

{{ with $css.Cached }}
{{ .Permalink }}
{{ else }}
<--- "process yourself logic" --->
{{ end }}