-
Hello all, I wanted to include plyr in my shortcode without referencing from an external site. To do so, I placed the necessary Method 1{{- $plyr := resources.Get "js/plyr.polyfilled.js" | minify | fingerprint}}
<head>
<script type="application/javascript" src="{{ $plyr.Permalink }}"></script>
</head> Results
To address the above issues, I tried another method, Methods 2{{- $blank := resources.Get "js/blank.js" }}
{{- $js := resources.Get "js/plyr.polyfilled.js" }}
{{- $plyr := (slice $blank $js) | resources.Concat "assets/js/plyr.js" | minify | fingerprint}}
<head>
<script type="application/javascript" src="{{ $plyr.Permalink }}"></script>
</head> I defined a dummy but I am wondering if there's a bit more elegant way to achieve so. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Answers to your questions and confirmation for your used method:
There's no need for referencing CSS files, because Papermod tells Hugo where to find them and what to with it, e.g. find the files in /assets/css/* and bundle it together. This is not something Hugo does, Papermod tells Hugo to do so. BUT, PaperMod only bundles CSS files, not JS files. So, in head.html there's no reference for "bundling" js files. The ones that do get included, but NOT bundled, are defined in head.html (HighLight.js and Fuse.js). So, no configuration error on your part. PaperMod doesn't bundle JS files. And with that, your second method is correct and the only one. Either define it in head.html or if you like JS to be bundled by default, you need to use CSS bundling code and adjust it for JS. |
Beta Was this translation helpful? Give feedback.
Answers to your questions and confirmation for your used method:
There's no need for referencing CSS files, because Papermod tells Hugo where to find them and what to with it, e.g. find the files in /assets/css/* and bundle it together. This is not something Hugo does, Papermod tells Hugo to do so.
BUT, PaperMod only bundles CSS files, not JS files. So, in head.html there's no reference for "bundling" js files. The ones that do get included, but NOT bundled, a…