SCSS Pipe Error: Resource transformation

Asset Dir

(and I’ve put _variables.scss in /assets/ and in /assets/scss/ and in /assets/sass/ and I can’t get it to be anything but Nil)

header.html partial:

{{ $style := resources.Get "_variables.scss" | resources.ToCSS }}
<link lazyload="1" href="{{ $style.Permalink }}" rel="stylesheet">

Error:
ERROR 2020/04/24 00:29:25 render of "page" failed: execute of template failed: template: page/single.html:4:5: executing "page/single.html" at <partial "head.html" .>: error calling partial: "partials/head.html:91:56": execute of template failed: template: partials/head.html:91:56: executing "partials/head.html" at <resources.ToCSS>: error calling ToCSS: type <nil> not supported in Resource transformations

With the css.css file in /assets, this works

{{ $style := resources.Get "css.css" | resources.Minify }}
<link lazyload="1" href="{{ $style.Permalink }}" rel="stylesheet">

Where exactly is one supposed to place scss files, and how to specify the correct path?

If I specify

{{ $style := resources.Get "scss/_variables.scss" | resources.ToCSS }}

Then I get
Error: Error building site: TOCSS: failed to transform "scss/_variables.scss" (text/x-scss): resource "scss/scss/_variables.scss_f300667da4f5b5f84e1a9e0702b2fdde" not found in file cach

So I am assuming from this error, that it would go into /assets/scss/_variables.scss but I’ve not had any luck trying various different paths.

Documentation says this:

In order to process an asset with Hugo Pipes, it must be retrieved as a resource using resources.Get, which takes one argument: the filepath of the file relative to the asset directory.

I am using relative path to /assets/ so I should specify reources.Get "_variables.scss?

Now I have

/assets/_variables.scss

And I specify:

{{ $style := resources.Get "_variables.scss" | resources.ToCSS }}
<link lazyload="1" href="{{ $style.Permalink }}" rel="stylesheet">

I get the following:

Error: Error building site: TOCSS: failed to transform "_variables.scss" (text/x-scss): resource "scss/_variables.scss_f300667da4f5b5f84e1a9e0702b2fdde" not found in file cache

Try

{{ $style := resources.Get “scss/_variables.scss” | resources.ToCSS }}

I have

/assets/_variables.scss

And I specify:

{{ $style := resources.Get "scss/_variables.scss" | resources.ToCSS }}
<link lazyload="1" href="{{ $style.Permalink }}" rel="stylesheet">

And I get the following:

Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: page/single.html:4:5: executing "page/single.html" at <partial "head.html" .>: error calling partial: "/layouts/partials/head.html:91:61": execute of template failed: template: partials/head.html:91:61: executing "partials/head.html" at <resources.ToCSS>: error calling ToCSS: type <nil> not supported in Resource transformations

I have

/assets/_variables.scss

And I specify: (with a preceding /)

{{ $style := resources.Get "/_variables.scss" | resources.ToCSS }}

I get:

Error: Error building site: TOCSS: failed to transform "_variables.scss" (text/x-scss): resource "scss/_variables.scss_f300667da4f5b5f84e1a9e0702b2fdde" not found in file cache

Drop the preceding “/”.

Now I have

/assets/_variables.scss

And I specify:

{{ $style := resources.Get "_variables.scss" | resources.ToCSS }}
<link lazyload="1" href="{{ $style.Permalink }}" rel="stylesheet">

I get:

Error: Error building site: TOCSS: failed to transform "_variables.scss" (text/x-scss): resource "scss/_variables.scss_f300667da4f5b5f84e1a9e0702b2fdde" not found in file cache

I specified this same thing in Post #2 here. I can’t seem to get this to work. I’ve tried all the paths variations and everything.

So, I don’t know what made me think of it, but I for some reason remembered or thought there is an extended version of Hugo, so I grabbed the latest release extended and now it seems to work properly.

Now I can do whatever paths/organisation in /assets I choose and it works well. Will you be porting this extended functionality to regular Hugo maybe? I did not know this or even understand this now :slight_smile:

Hmm … OK. Looks like we need to look into the error message.

1 Like

How can I help?

In short, I was hoping that you would get this more informational message (or in addition to the one you got):

That makes more sense. Thank you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.