SRI for a remote resource (hugo 0.89)

I want to let hugo automatically create SRI for a remote resource fetched via URL, e.g.:

{{ $js := resources.Get "https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js" }}
{{ $secureJS := $js | resources.Fingerprint "sha512" }}
<script type="text/javascript" src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>

This works great with latest hugo v0.90.0-DEV+extended.
Any ideas on how to make that work with current hugo 0.89.x or earlier versions? I know I can store the .js file locally in the assets folder, but that’s not what I want.

No this is not possible in earlier versions of Hugo.

The feature will be available in the 0.90.0 version.

2 Likes

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