resources.Fingerprint
Returns a fingerprinted resource, created by cryptographically hashing the content of the given resource.
- Syntax
- resources.Fingerprint [ALGORITHM] RESOURCE
- Returns
- resource.Resource
- Alias
- fingerprint
This works with global resources, page resources, and remote resources.
{{ with resources.Get "js/main.js" }}
{{ with . | fingerprint "sha256" }}
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ end }}Hugo renders this to something like:
<script src="/js/main.62e...df1.js" integrity="sha256-Yuh...rfE=" crossorigin="anonymous"></script>Although most commonly used with CSS and JavaScript resources, you can use the resources.Fingerprint function with any resource type.
The hash algorithm may be one of md5, sha256 (default), sha384, or sha512.
After cryptographically hashing the resource content:
- The values returned by the
PermalinkandRelPermalinkmethods include the hash sum - The resource’s
.Data.Integritymethod returns a Subresource Integrity (SRI) value consisting of the name of the hash algorithm, one hyphen, and the base64-encoded hash sum
Last updated:
November 8, 2026
:
content: Remove categories from front matter (1cc1dd83a)
Improve this page