Make cache bust hashes optional.

This commit is contained in:
Fredrik Jonsson 2017-03-20 22:31:10 +01:00
commit 0d35371f5f
3 changed files with 4 additions and 2 deletions

View file

@ -58,6 +58,8 @@ params:
slicknav: true # Activates SlickNav, a nice mobile menu. slicknav: true # Activates SlickNav, a nice mobile menu.
search: true # Site search with DuckDuckGo. search: true # Site search with DuckDuckGo.
searchSize: 20 # Search field size, default 20. searchSize: 20 # Search field size, default 20.
cacheBustCSS: true # Add a cache busting hash on styles.css
cacheBustJS: true # Add a cache busting hash on script.js
``` ```

View file

@ -2,7 +2,7 @@
<meta name="MobileOptimized" content="width"> <meta name="MobileOptimized" content="width">
<meta name="HandheldFriendly" content="true"> <meta name="HandheldFriendly" content="true">
{{ .Hugo.Generator }} {{ .Hugo.Generator }}
<link rel="stylesheet" href="/css/styles.css?{{ readFile "/public/css/styles.css" | sha1}}"> <link rel="stylesheet" href="/css/styles.css{{ if .Site.Params.cacheBustCSS }}?{{ readFile "/public/css/styles.css" | sha1 }}{{ end }}">
<link rel="canonical" href="{{ .Permalink }}"> <link rel="canonical" href="{{ .Permalink }}">
<link rel="shortcut icon" href="{{ .Site.BaseURL }}favicon.ico" type="image/vnd.microsoft.icon"> <link rel="shortcut icon" href="{{ .Site.BaseURL }}favicon.ico" type="image/vnd.microsoft.icon">
<link rel="apple-touch-icon" href="{{ .Site.BaseURL }}apple-touch-icon.png"> <link rel="apple-touch-icon" href="{{ .Site.BaseURL }}apple-touch-icon.png">

View file

@ -1,3 +1,3 @@
{{ if .Site.Params.jquery }}<script src="/js/jquery.min.js"></script>{{ end }} {{ if .Site.Params.jquery }}<script src="/js/jquery.min.js"></script>{{ end }}
{{ if and .Site.Params.jquery .Site.Params.slicknav }}<script src="/js/jquery.slicknav.min.js"></script>{{ end }} {{ if and .Site.Params.jquery .Site.Params.slicknav }}<script src="/js/jquery.slicknav.min.js"></script>{{ end }}
{{ if .Site.Params.jquery }}<script src="/js/script.js?{{ readFile "/public/js/script.js" | sha1}}"></script>{{ end }} {{ if .Site.Params.jquery }}<script src="/js/script.js{{ if .Site.Params.cacheBustJS }}?{{ readFile "/public/js/script.js" | sha1 }}{{ end }}"></script>{{ end }}