Description
What version of Hugo are you using (0.126.1
)?
$ hugo version: 0.125.x and 0.126.x
Does this issue reproduce with the latest release?
Yes
Setup
Hugo 1.125/126
PostCss
Node 22
Issue
When using hugo pipes to process/generate a css file, and then using the css file in the html, since 0.125+ hugo tries to render the html pages before the css has ben processed, causing any change in a file detected by livereload to cause hugo server to fail, needing to be manually restarted.
This is due to the resource trying to be accessed not yet existing with message
Rebuild failed: render: failed to render pages: render of "page" failed: "/REDACTED/file.html:4:3": execute of template failed at <partial "head-content.html" .>: error calling partial: "/REDACTED/file2.html:114:27": execute of template failed at <$processedCSS.Content>: error calling Content: file does not exist
Hugo server is ran like:
hugo server --noHTTPCache --disableFastRender --ignoreCache --gc
Restarting hugo server fixes it, and its only when livereload triggers a refresh.
Example:
htmlfile.html
{{/* Combine, purge, minify and cssnano these css files */}}
{{ $twCSS := resources.Get "assets/css/file1.css"}}
{{ $mainCSS := resources.Get "assets/css/main.css" }}
{{ $tailwindDevCSS := resources.Get "assets/css/file2.css"}}
{{ $mdCSS := resources.Get "assets/css/markdown.css" }}
{{ $gradiaCSS := resources.Get "assets/css/file3.css"}}
{{ $combinedCSS := slice $file1 $file2 $file3 $mainCSS $mdCSS | resources.Concat "assets/css/outputfilename.css" }}
{{ $processedCSS := $combinedCSS | resources.PostCSS | fingerprint }}
Inlining the css in the same file:
<style keep>
{{printf "%s" $processedCSS.Content | safeCSS}}
</style>
Fix
I havent had time to look trough the code but the issue started from 0.125+ and is only appearing when running hugo server and is consistently happening on every change livereload detects. Does disablefastrendersomehow not cause a full reload?