How to pass an URL defined in config?

I would like to set in my config.toml my dependencies

cdn_bs_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

How to leave strings unmodified ?
I have the same problem with CSS declaration
cdn_md_icon = “” where Hugo replaces Material+Icons with Material+Icons

Thanks a lot

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

Hi, thx for your answer
in my config.toml I have
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.

Solved with
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">

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.