add cache busting for CSS files via Hugo Pipes
Aron Gergely aron.gergely@rasterra.nl
Fri, 04 Jun 2021 23:34:27 +0200
4 files changed,
6 insertions(+),
3 deletions(-)
M
layouts/partials/header.html
→
layouts/partials/header.html
@@ -32,11 +32,14 @@ <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@1,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet"> {{- else -}} - <link href="{{ .Site.BaseURL }}css/fonts.css" rel="stylesheet"> + {{ $fontstyle := resources.Get "css/fonts.css" | fingerprint }} + <link href="{{ $fontstyle.Permalink }}" rel="stylesheet"> {{ end }} - <link rel="stylesheet" type="text/css" media="screen" href="{{ .Site.BaseURL }}css/main.css" /> + {{ $style := resources.Get "css/main.css" | fingerprint }} + <link rel="stylesheet" type="text/css" media="screen" href="{{ $style.Permalink }}" /> {{- if or (eq .Site.Params.mode "auto") (eq .Site.Params.mode "dark") -}} - <link rel="stylesheet" type="text/css" href="{{ .Site.BaseURL }}css/dark.css" {{ if eq .Site.Params.mode "auto" }}media="(prefers-color-scheme: dark)"{{ end }} /> + {{ $darkstyle := resources.Get "css/dark.css" | fingerprint }} + <link rel="stylesheet" type="text/css" href="{{ $darkstyle.Permalink }}" {{ if eq .Site.Params.mode "auto" }}media="(prefers-color-scheme: dark)"{{ end }} /> {{ end }} <!-- Custom CSS style get applied last --> {{- if isset .Site.Params "customcss" }}