error calling fingerprint: <nil> is not a Resource
Got the above and similar when porting gohugoioTheme to a module in Hugo Docs today.
@bep How was this solved? I am running into a very similar issue on Cactus theme
executing "partials/head.html" at <toCSS>: error calling toCSS: type <nil> not supported in Resource transformations
You need to do a nil check in the templates. The thing is, resource.Get "someresource.css" returns nil if not found.
We could probably improve the error message, but you need to do something ala:
{ { $scss := resource.Get "foo.scss" }}
{{ if $scss }}
// call toSCSS
{{ end }}
If my files are under the assets folder: resources/_gen/assets/sass/main.scss, I don't understand why it can't find it.
{{ $style := resources.Get "sass/main.scss" | toCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}">
@dallashudgens The documentation states the following:
Asset files must be stored in the asset directory. This is /assets by default, but can be configured via the configuration file鈥檚 assetDir key.
then given the example on that page:
{{ $style := resources.Get "sass/main.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}">
I ended up with the same error.
So I've decided to add a / to the beginning of the resources.Get "/sass/main.scss" and voila it worked 馃槃
I am totally new to Hugo and am just giving a go, I understand the frustration when trying something new and it doesn't work as expected.
I'm finding that hugo server needs to be stopped and restarted after asset files have been placed in /assets in order for resources.Get to work. Probably worth mentioning in the docs. :)
Edit: subsequently added asset files are being successfully picked up without stopping and starting the server.
This is highly confusing.
I've tried the following paths:
/static/assets/scss
/resources/_gen/assets/scss
/themes/mytheme/static/assets/scss
/themes/mytheme/resources/_gen/assets/scss
the call to resource.Get is inside my baseof inside mytheme
None of this works.
Ideas?
Most helpful comment
I'm finding that
hugo serverneeds to be stopped and restarted after asset files have been placed in/assetsin order forresources.Getto work. Probably worth mentioning in the docs. :)Edit: subsequently added asset files are being successfully picked up without stopping and starting the server.