Search
Items tagged with: hugo
Reply to Shorter fingerprinting (Hugo issue 6241) by XhmikosR
I use a quick crypto.FNV32a
-based fix for short cache-busting fingerprints that doesn’t directly rely on the unstable .Key
method.
I use Hugo’s crypto.FNV32a
to generate a short hash, then copy the resource to a new path with that fingerprint.
{{ $resource := resources.Get . -}}
{{- $target_path_formatStr := (replaceRE `(\.[^\.]*)$` ".%d$1" .) -}}
{{- $cacheBuster := $resource.Content | crypto.FNV32a -}}
{{- $target_path := printf $target_path_formatStr $cacheBuster -}}
{{- return resources.Copy $target_path $resource -}}
You can see it used in my site’s head
element. I invoke it using partialCached
so the fingerprinting only happens once per resource:{{ $icon_svg := partialCached "cache-bust.html" "/favicon.svg" "/favicon.svg" }}
{{- printf `<link rel="icon" sizes="any" href="%s" type="image/svg+xml" />` $icon_svg.RelPermalink | safeHTML }}
Here’s a snippet of the final rendered result:<span><a href="#cb1-1"></a><span><</span><span>link</span><span> rel</span><span>=</span><span>"icon"</span><span> sizes</span><span>=</span><span>"any"</span><span> href</span><span>=</span><span>"/favicon.2229316949.svg"</span><span> type</span><span>=</span><span>"image/svg+xml"</span><span>/></span></span>
Encoding it to a higher base and using alphanumerics could shave off 1-2 ch.
Originally posted on seirdy.one: See Original (POSSE). #Hugo
Seirdy’s Home
My personal IndieWeb site. I write about and develop software to promote user autonomy. Topics include accessibility, security, privacy, and software freedom.Seirdy’s Home
#Hugo's slogan of being "The world’s fastest framework for building websites" is a shameless lie.
It has been raised up 3 times on Github with benchmarks showing that other full-featured static site generators like #Zola (#Rust) are faster, sometimes by 10x. Each time, the issue is closed and locked.
I migrated a couple of websites from Hugo to Zola and won't look back.
Feel free to ping me if you need any help with Zola 🥰
Cactus Comments: a solution respecting privacy for the websites built with Hugo | NicFab Notes | Our view on #Cactus #Comments based on #Matrix protocol, its integration with #Hugo, and respecting the #PbD correct approach - https://buff.ly/3qnorcZ @matrixdotorg@twitter.com @GoHugoIO@twitter.com
🐦🔗: https://twitter.com/nicfab/status/1475011591422754816
Cactus Comments: a solution respecting privacy for the websites built with Hugo
How to set up Cactus Comments on the website built with Hugo: it’s possible to opt for an approach Privacy by Design.NicFab (NicFab Notes)