# Can't read SASS files with Hugo

**URL:** https://discourse.gohugo.io/t/cant-read-sass-files-with-hugo/31719
**Category:** support
**Tags:** netlify
**Created:** [March 12, 2021, 6:26am UTC](https://discourse.gohugo.io/t/cant-read-sass-files-with-hugo/31719 "2021-03-12T06:26:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![hoshility](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hoshility/32/13841_2.png) [@hoshility](https://discourse.gohugo.io/u/hoshility)
#### Post date: [March 12, 2021, 6:26am UTC](https://discourse.gohugo.io/t/cant-read-sass-files-with-hugo/31719/1 "2021-03-12T06:26:52Z")

</div>

Dear Excellent developes.

I’m trying to duild static web site with Hugo (Netlify CMS). I wanna build from scratch, if I can;-) ( I designed the site by myself. So, I hope to write sass from scratch).

But, sass files aren’t read successflly. Do you solve the problem?

# I checked there pages to solve it , But I couldn’t

- [SASS / SCSS | Hugo](https://gohugo.io/hugo-pipes/scss-sass/)
- [Custom CSS throws: Type \<nil\> not supported in Resource transformations](https://discourse.gohugo.io/t/custom-css-throws-type-nil-not-supported-in-resource-transformations/19942)

# The structure of this Web site

Basically, there are not many changes from Hugo install.

- layouts/index.html // I write there the following code.
- resources/\_gen/assets/sass/main.scss // I wrote simple css to this file → html {background: yellow;}

# layouts/index.html

```auto
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>Document</title>
  <script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
  {{ $sassTemplate := resources.Get "sass/main.scss" }}
  {{ $style := $sassTemplate | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS }}
  <link rel="stylesheet" href="{{ $style.relURL }}">
</head>

<body>
  <h1>Nice. It's looking good already.</h1>
  <ul>
    {{ range (where .Pages "Section" "blog") }}
    <li>
      <a href="{{ .RelPermalink }}">
        {{ .Title }}
      </a>
    </li>
    {{ end }}
  </ul>
</body>

</html>

```

# Error messages

```auto
Rebuild failed:

Failed to render pages: render of "home" failed: "/Users/RPOISITORY-NAME/layouts/index.html:11:40": execute of template failed: template: index.html:11:40: executing "index.html" at <resources.ExecuteAsTemplate>: error calling ExecuteAsTemplate: type <nil> not supported in Resource transformations
↓
  <script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
  {{ $sassTemplate := resources.Get "sass/main.scss" }}
  {{ $style := $sassTemplate | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS }}
  <link rel="stylesheet" href="{{ $style.relURL }}">
</head>

hugo v0.81.0+extended darwin/amd64 BuildDate=unknown

```

Thanks in advance.

---

<div class="post-metadata">

### Author: ![joeborg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/joeborg/32/12657_2.png) [@joeborg](https://discourse.gohugo.io/u/joeborg)
#### Post date: [March 12, 2021, 6:37am UTC](https://discourse.gohugo.io/t/cant-read-sass-files-with-hugo/31719/2 "2021-03-12T06:37:53Z")

</div>

AFAIK \_gen is a working directory created by hugo to process the site.

You need to put your scss and other referenced files in the assets directory as indicated here:

> **[Directory Structure](https://gohugo.io/getting-started/directory-structure/)**
>
> Hugo's CLI scaffolds a project directory structure and then takes that single directory and uses it as the input to create a complete website.

unfortunately the directory tree depicted is missing the assets folder.

follow up by trying to understand this section:

> **[Configure Modules](https://gohugo.io/hugo-modules/configuration/#module-config-mounts)**
>
> This page describes the configuration options for a module.

hope this helps you get on your way.

---

<div class="post-metadata">

### Author: ![hoshility](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hoshility/32/13841_2.png) [@hoshility](https://discourse.gohugo.io/u/hoshility)
#### Post date: [March 12, 2021, 6:58am UTC](https://discourse.gohugo.io/t/cant-read-sass-files-with-hugo/31719/3 "2021-03-12T06:58:35Z")

</div>

Dear joeborg

Oh, Thank you very much…!!  
I tried to solve the problem all the night yesterday…  
I would like to try them.

---

<div class="post-metadata">

### Author: ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)
#### Post date: [March 12, 2021, 11:30am UTC](https://discourse.gohugo.io/t/cant-read-sass-files-with-hugo/31719/4 "2021-03-12T11:30:13Z")

</div>

As @joeborg noted, your asset files belong into `assets`. The folder `resources` is dynamically created and used by Hugo to cache prepared asset files:

```auto
  {{ $sassTemplate := resources.Get "sass/main.scss" }}

```

This line looks for the file in `/assets/sass/main.scss`.

---

<div class="post-metadata">

### Author: ![hoshility](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hoshility/32/13841_2.png) [@hoshility](https://discourse.gohugo.io/u/hoshility)
#### Post date: [March 12, 2021, 5:02pm UTC](https://discourse.gohugo.io/t/cant-read-sass-files-with-hugo/31719/5 "2021-03-12T17:02:02Z")

</div>

Oh… My … GOD!!!  
It seems that it succeed…!!!  
I can’t believe…!!! I let out a cry of joy without thinking…!!!

The answer was follows:

# Path of the sass file

- REPOISITORY-NAME/sass/main.scss
  - → the compiled file is in REPOISITORY-NAME/resources/\_gen/assets/scss/sass/main.scss\_2538feeffcbb857f4cc8772ebe8a0cd3.content

@joeborg @davidsneighbour Thank you for your advice…!!

But I came up with another question.  
Which is pure compiled css file?🤔 There is no `main.css` file in the repo nevertheless `main.css` is expressed in browser↓  
`<link rel="stylesheet" href="http://localhost:1313/main.css">`

# index.html

```auto
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>Document</title>
  <script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
  {{ $sassTemplate := resources.Get "sass/main.scss" }}
  {{ $style := $sassTemplate | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS }}
  <link rel="stylesheet" href="{{ $style.Permalink }}">
</head>

<body>
  <h1>Nice. It's looking good already.</h1>
  <ul>
    {{ range (where .Pages "Section" "blog") }}
    <li>
      <a href="{{ .RelPermalink }}">
        {{ .Title }}
      </a>
    </li>
    {{ end }}
  </ul>
</body>

</html>

```

As you know I’m a Hugo beginner, I will post other questions in here again.  
Anyway, This problem was solved. Thank you very much @joeborg and @davidsneighbour !!!

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)
#### Post date: [March 14, 2021, 5:02pm UTC](https://discourse.gohugo.io/t/cant-read-sass-files-with-hugo/31719/6 "2021-03-14T17:02:22Z")

</div>

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