I load it with resources.Get, execute it with resources.ExecuteAsTemplate, transpile it with toCSS, minimize it, fingerprint it, and refer to it in a <link> href attribute.
This all works fine in basic cases. If I don’t set paige.color in the site or page parameters, the color is the default #0d6efd. If I set it in the site parameters, the color is changed as you’d expect. However, if I set it in a page, it doesn’t work; it still uses the default color.
I’m guessing what’s happening is the template is rendering only once, for some reason, but I don’t understand why.
resources.ExecuteAsTemplate output will be cached after its first execution, the TARGET_PATH is the cache key. You need to create unique target path for each resources.ExecuteAsTemplate.
The sha1 prefixes are different (2960a7c… vs. 069706…), which is expected, since the colors are different; but the fingerprints are the same (025067…), so the Bootstrap colors are still the same, and so are the contents.
Does the @import "bootstrap" really works/resolved/imported here? because the $primary var only used in Sass/dartsass runtime and Hugo create fingerprint based on the compiled css.
@pamubay I’m not sure what you’re asking. The sha1 hash is of the $.page value, so it should be different for each unique color value, which is in $.page.Params.paige.color. There’s another hash—a SHA-256 hash—that appears near the end of the file names, which is the result of the fingerprint function, which hashes the contents of the file after the SCSS transpilation…
The CSS, SCSS, and JS files in the Bootstrap NPM package are mounted to /assets/paige/bootstrap, so when dartsass runs, @import "bootstrap" imports bootstrap.scss from the bootstrap package.
Good news! That patch does indeed work. There must have been a build cache bug. I had to restart my computer, which killed hugo server. Restarting hugo server must have fixed it. @pamubay Thanks for your help!