hugo
hugo copied to clipboard
Make resource.PostProcess work with relativeURLs=true
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