Move favicons to seperate partial so it can use partialCached. Remove realfavicongenerator setting and autodetect favicon files instead.
This commit is contained in:
parent
91950cbbfa
commit
2bea24168e
4 changed files with 20 additions and 9 deletions
|
|
@ -293,7 +293,6 @@ params:
|
|||
plausibleTrackerURL: "" # Plausible url, schemaless and no slash on end. Optional, defaults to "plausible.io/…"
|
||||
poweredby: true # Show powered by hugo in footer
|
||||
privacyPolicyUrl: "" # If set will add link to cookie consent form.
|
||||
realfavicongenerator: # If full set of favicons, site manifest etc. exists, default false.
|
||||
relatedposts: true # Show related posts under a "See also" section, default false.
|
||||
sassTranspiler: "dartsass"# The Sass transpiler to use, default "libsass".
|
||||
searchLimit: 20 # Max number of search hits, default 20.
|
||||
|
|
@ -360,9 +359,9 @@ Place your logo at `static/images/logo.png`. If you don't provide a logo, then t
|
|||
|
||||
### Favicons
|
||||
|
||||
Upload your image to [RealFaviconGenerator](https://realfavicongenerator.net/) then copy-paste the generated favicon files under `static`.
|
||||
Upload your image to [RealFaviconGenerator](https://realfavicongenerator.net/) then copy the generated favicon files in to the `static` directory. (Do not place them in a sub directory.)
|
||||
|
||||
Then set the "realfavicongenerator" param to true to add the needed meta tags. Also good to set the "themeColor" param to correct colour.
|
||||
The theme will autodetect them and add the needed code.
|
||||
|
||||
|
||||
### Head and footer partials
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width">
|
||||
<title>{{ block "title" . }}{{ .Title }} – {{ site.Title }}{{ end }}</title>
|
||||
{{ partial "meta.html" . }}
|
||||
{{ partialCached "favicons.html" . }}
|
||||
{{ partialCached "styles.html" . }}
|
||||
{{ partial "meta_json_ld.html" . }}
|
||||
{{ partial "scripts.html" . }}
|
||||
|
|
|
|||
17
layouts/partials/favicons.html
Normal file
17
layouts/partials/favicons.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{{ if fileExists (path.Join "/static" "apple-touch-icon.png") -}}
|
||||
<link rel="apple-touch-icon" href="{{ "apple-touch-icon.png" | relURL }}">
|
||||
{{ end -}}
|
||||
{{ if fileExists (path.Join "/static" "favicon.svg") -}}
|
||||
<link rel="icon" type="image/svg+xml" href="{{ "favicon.svg" | relURL }}">
|
||||
{{ end -}}
|
||||
{{ if fileExists (path.Join "/static" "site.webmanifest") -}}
|
||||
<link rel="manifest" href="{{ "site.webmanifest" | relURL }}">
|
||||
{{ end -}}
|
||||
{{ $favname := "" -}}
|
||||
{{ $favsizes := slice "128x128" "96x96" "48x48" "32x32" "16x16" -}}
|
||||
{{ range $favsizes -}}
|
||||
{{ $favname = (printf "favicon-%s.png" .) -}}
|
||||
{{ if fileExists (path.Join "/static" $favname) -}}
|
||||
<link rel="icon" type="image/png" {{ printf "sizes=%q" . | safeHTMLAttr }} href="{{ $favname | relURL }}">
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
|
@ -23,9 +23,3 @@
|
|||
<link rel="alternate" hreflang="{{ .Site.LanguageCode | default .Lang }}" href="{{ .Permalink }}">
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
<link rel="apple-touch-icon" href="{{ "apple-touch-icon.png" | relURL }}">
|
||||
{{ if $.Param "realfavicongenerator" -}}
|
||||
<link rel="icon" type="image/png" sizes="96x96" href="{{ "favicon-96x96.png" | relURL }}">
|
||||
<link rel="icon" type="image/svg+xml" href="{{ "favicon.svg" | relURL }}">
|
||||
<link rel="manifest" href="{{ "site.webmanifest" | relURL }}">
|
||||
{{ end -}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue