monkeyWzr / hugo-theme-cactus

Cactus theme for hugo
MIT License
541 stars 341 forks source link

Can't customize head.html after moving to SCSS #82

Closed waterlens closed 3 years ago

waterlens commented 3 years ago

because the new code added to head.html:

  {{- $options := (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") -}}
  {{- $styles := resources.Get "scss/style.scss" | resources.ExecuteAsTemplate "scss/style.scss" . | resources.ToCSS $options | resources.Fingerprint "sha512" }}
  <link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}"> 

hugo reports errors when I copy head.html from the themes directory to the project directory

Nizzlay commented 3 years ago

@waterlens

Can you please share the errors that you get?

waterlens commented 3 years ago

@waterlens

Can you please share the errors that you get?

@Nizzlay

Yeah. I guess that might be a problem related to relevant path?

ERROR 2021/07/08 XX:XX:XX Rebuild failed:
ERROR 2021/07/08 XX:XX:XX TOCSS: failed to transform "scss/style.scss" (text/x-scss): SCSS processing failed: file "stdin", line 2, col 1: File to import not found or unreadable: colors/<no value>.
daleige commented 3 years ago

Yes, I have the same bug

TOCSS: failed to transform "scss/style.scss" (text/x-scss): SCSS processing failed: file "stdin", line 2, col 1: File to import not found or unreadable: colors/<no value>.
waterlens commented 3 years ago

I found the problem.

  {{ .Scratch.Set "colortheme" "white"}}
  {{ if .Site.Params.Colortheme }}
    {{ .Scratch.Set "colortheme" .Site.Params.Colortheme }}
  {{ end }}
  {{ $colortheme := .Scratch.Get "colortheme" }}

In the past, this block of code will set the default $colortheme if no .Site.Params.Colortheme, and we eventually use $colortheme to reference a css. But now in style.scss site.Params.Colortheme was used directly, and there is no default value if we don't set it in config.toml.

monkeyWzr commented 3 years ago

@waterlens @daleige @Nizzlay Hi there Really sorry for the inconvenience. I forget to set the default colortheme value so if you don't have colortheme set in your config file, the build will fail. This should be fixed by #88. The white theme is used by default. Check it out! Sorry again and best regards!

waterlens commented 3 years ago

Yeah, the problem has been solved.