gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.92k stars 7.54k forks source link

Make resource.PostProcess work with relativeURLs=true #7316

Open Traumflug opened 4 years ago

Traumflug commented 4 years ago

Version 0.71.1


I use to process resources like this:

{{ $style := resources.Get "scss/main.scss" }}
{{ $style = $style | resources.ToCSS (dict "enableSourceMap" true) }}
{{ $style = $style | resources.PostCSS (dict "config" "assets/postcss.config.js") }}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">

If I add PostProcess and keep everything else the same, like ...

{{ $style := resources.Get "scss/main.scss" }}
{{ $style = $style | resources.ToCSS (dict "enableSourceMap" true) }}
{{ $style = $style | resources.PostCSS (dict "config" "assets/postcss.config.js") }}
{{ $style = $style | resources.PostProcess }}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">

... and compare the build result to the previous build, I get a diff like this in every HTML file:

diff -U1 -r public-before/pages/imprint.html public/pages/imprint.html
--- public-before/pages/imprint.html    2020-05-25 16:15:59.345247741 +0200
+++ public/pages/imprint.html   2020-05-25 16:16:52.813056465 +0200
@@ -30,3 +30,4 @@

-<link rel="stylesheet" href="../scss/main.css">
+
+<link rel="stylesheet" href="/scss/main.css">

As far as I can tell, delaying CSS processing shouldn't affect HTML generation at all.

Configuration maybe related:

relativeURLs:   true
uglyurls:       true
Traumflug commented 4 years ago

This still happens in 0.74.3.