Issue with Assets

Hello, I have some scss and js files in the assets folder, but hugo doesn’t render them.
you can see the error and my syntex below.

error

ERROR 2021/01/31 22:36:04 render of “taxonomy” failed: “C:\Users\Yousaf\Documents\GitHub\nubia\layouts_default\list.html:10:34”: execute of template failed: template: _default/list.html:10:34: executing “_default/list.html”
at <resources.ToCSS>: error calling ToCSS: type not supported in Resource transformations
ERROR 2021/01/31 22:36:04 render of “home” failed: “C:\Users\Yousaf\Documents\GitHub\nubia\layouts_default\list.html:10:34”: execute of template failed: template: _default/list.html:10:34: executing “_default/list.html” at <resources.ToCSS>: error calling ToCSS: type not supported in Resource transformations
Built in 21 ms
Error: Error building site: failed to render pages: render of “taxonomy” failed: “C:\Users\Yousaf\Documents\GitHub\nubia\layouts_default\list.html:10:34”: execute of template failed: template: _default/list.html:10:34: executing “_default/list.html” at <resources.ToCSS>: error calling ToCSS: type not supported in Resource transformations

santex
{{ $sass := resources.Get "sass/app.scss" }}
{{ $style := $sass | resources.ToCSS }}
<link rel="stylesheet" src="{{ $style.Permalink }}">

try something like this

{{- $sass := resources.Get "sass/app.scss" | resources.ExecuteAsTemplate "sass/app2.scss" . | toCSS }}

not working sir.

Well, I said something like this code. You have to adapt/test it.

This is a piece of working code:

{{ "<!-- Main Stylesheet -->" | safeHTML }}
{{- $style_original := resources.Get "scss/style_original.scss" | resources.ExecuteAsTemplate "css/style.scss" . | toCSS }}
{{- $style_site     := resources.Get "css/camping.css" }}
{{- $css := slice $style_original $style_site | resources.Concat "css/style_main.css" }}
{{- if $isProd }}
   <!-- Utilise PurgeCSS -->
   {{- if site.Params.purgecss }}
      {{/*- $css = $css | resources.PostCSS $options */}}
   {{- end }}
   {{- $css = $css | minify | fingerprint "sha384" }}
{{- end }}
<link href="{{ $css.RelPermalink }}" {{ if $isProd }}integrity="{{ $css.Data.Integrity }}"{{ end }} rel="stylesheet" type="text/css"/> 

Sir I am in learning phase, that’s why I don’t know the advancements in hugo. There’re no other mentor except this forum.

Hey, there is no problem.
I just said that my first response was not tested, so you have to test/adapt.

If you look at my code, you should get something working for you.

@yousafblogger please read Requesting Help .

We cannot see the full picture of what your site code looks like because we can only see the snippet. We don’t know why it isn’t working. Please include a link to your site code repo if you want more specific help.

1 Like