djibe
April 15, 2020, 10:38am
1
Hi,
I would like to set in my config.toml my dependencies
cdn_bs_js = “https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.bundle.min.js ”
cdn_bs_js_hash = “sha256-OUFW7hFO0/r5aEGTQOz9F/aXQOt+TwqI1Z4fbVvww04=”
And call these from my partials/footer.html with
However, Hugo breaks integrity and compiles HTML like
integrity=“sha256-OUFW7hFO0/r5aEGTQOz9F/aXQOt**+**TwqI1Z4fbVvww04=”
How to leave strings unmodified ?
I have the same problem with CSS declaration
cdn_md_icon = “https://fonts.googleapis.com/css2?family=Material+Icons ” where Hugo replaces Material+Icons with Material+Icons
Thanks a lot
regis
April 15, 2020, 11:58am
2
Have you tried safeHTMLAttr
? I’m not sure where in your template you’re calling these strings, but depending, there’s a bunch of safe...
functions to tell Hugo to parse certain strings as is, safeCSS
, safeHTML
, safeHTMLAttr
etc…
1 Like
djibe
April 17, 2020, 2:28pm
3
Hi, thx for your answer
in my config.toml I have
[params.cdn]
bs_js_hash = “sha256-OUFW7hFO0/r5aEGTQOz9F/aXQOt+TwqI1Z4fbVvww04=”
and in my footer.html
Tried all safe(x) utilities, it doesn’t work and the “+” gets converted to “+”.
Thanks a lot for your time.
djibe
April 22, 2020, 2:50pm
4
Solved with https://discourse.gohugo.io/t/how-to-prevent-hugo-from-parsing-to-43/22214
To pass CSS or JS librairies URLs, we just need printf like this :
<link {{ printf "href=%q" .Site.Params.cdn.md_font | safeHTMLAttr }} rel="stylesheet">
system
Closed
April 24, 2020, 2:50pm
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.