Problem chaining toCSS and postCSS


I have a problem when trying to call postCSS on a CSS toCSS method.

For instance:

{{ $style := $sass | toCSS | postCSS }}


Error: Error building site: POSTCSS: failed to transform "css/main.css" (text/css): resource "scss/css/main.scss_832876c32a71faa43531d9a08ead6e38" not found in file cache

Both {{ $style := $sass | toCSS }} and {{ $style := $css | postCSS }} work fine (except if $css is the result of toCSS).

Am I missing something here, maybe in my configuration?
The error message makes me think it’s not related to anything I could have done, but still…

I made a minimal project reproducing this case: (branch bug/postcss).

Hugo version is 0.68.3.

Thanks in advance.

A bad commit made it into the Hugo releases of versions 0.67.1 - 0.68.0

The commit was reverted in 0.68.1

It seems that the theme you are using generated its resources with one of the above versions.

To solve the issue, you need to regenerate the resources of the theme, with Hugo Extended v0.68.3 also you can notify the theme author to do the same and update the theme repo.

Hey, thank you. That’s interesting.

I actually don’t use a theme.
All the layouts are directly under the layouts directory.

I made some tests with my minimal case project (details below).
They indeed seem to indicate that version 0.67.0 works fine, but version 0.68.1 through 0.68.3 all return the same error as above.

I used hugo env to make sure I was running the correct version (not always obvious because I use the hugo-bin wrapper), and it was correct.
Does it mean another bug may have been missed because of the faulty commit?

Test details

Hugo Static Site Generator v0.68.(1|2|3)/extended windows/amd64:
ERROR 2020/03/26 19:05:41 POSTCSS: failed to transform "css/main.css" (text/css): resource "scss/css/main.scss_832876c32a71faa43531d9a08ead6e38" not found in file cache

Hugo Static Site Generator v0.67.0/extended windows/amd64:
ERROR 2020/03/26 19:07:37 Transformation failed: POSTCSS: failed to transform "css/sample.css" (text/css): resource "css/css/sample.css_674d3a8c056e8697f10ad004211806b8" not found in file cache. Check your PostCSS installation; install with "npm install postcss-cli". See

Hugo Static Site Generator v0.67.0/extended windows/amd64 + postcss-cli: no error

No idea. I only know what I’ve been told and what I saw first hand at the Hugo Themes repo when some 32 theme demos broke.

The question can only be answered by the maintainer.

cc: @bep

For whatever it’s worth, I had this same bug and just removed the additional pipes related to PostCSS and this seemed to fix the issue.

What I had before that threw the same file cache error:

{{ $cssOpts := (dict "targetPath" "css/style.css" ) }}
    {{ $styles := resources.Get "scss/style.scss" | toCSS $cssOpts | postCSS | minify }}
    <link rel="stylesheet" href="{{ $styles.RelPermalink }}" media="screen">

What I have now that seems to be working when building locally:

{{ $cssOpts := (dict "targetPath" "css/style.css" ) }}
    {{ $styles := resources.Get "scss/style.scss" | toCSS $cssOpts }}
    <link rel="stylesheet" href="{{ $styles.RelPermalink }}" media="screen">
1 Like

I got the same error message while deploying a page to Gitlab Pages. The source of the error was my flawed config file: I had incorrectly specified the baseURL = "" rather than
baseURL = "", having forgotten the name of the repo at the end.