diff --git a/README.md b/README.md index cb92e46..a6eab61 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 22dd14c..0b52779 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -5,6 +5,7 @@ {{ block "title" . }}{{ .Title }} – {{ site.Title }}{{ end }} {{ partial "meta.html" . }} +{{ partialCached "favicons.html" . }} {{ partialCached "styles.html" . }} {{ partial "meta_json_ld.html" . }} {{ partial "scripts.html" . }} diff --git a/layouts/partials/favicons.html b/layouts/partials/favicons.html new file mode 100644 index 0000000..be510dd --- /dev/null +++ b/layouts/partials/favicons.html @@ -0,0 +1,17 @@ +{{ if fileExists (path.Join "/static" "apple-touch-icon.png") -}} + +{{ end -}} +{{ if fileExists (path.Join "/static" "favicon.svg") -}} + +{{ end -}} +{{ if fileExists (path.Join "/static" "site.webmanifest") -}} + +{{ end -}} +{{ $favname := "" -}} +{{ $favsizes := slice "128x128" "96x96" "48x48" "32x32" "16x16" -}} +{{ range $favsizes -}} +{{ $favname = (printf "favicon-%s.png" .) -}} +{{ if fileExists (path.Join "/static" $favname) -}} + +{{ end -}} +{{ end -}} diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index 5218b85..1a5b0a4 100644 --- a/layouts/partials/meta.html +++ b/layouts/partials/meta.html @@ -23,9 +23,3 @@ {{ end -}} {{ end -}} - -{{ if $.Param "realfavicongenerator" -}} - - - -{{ end -}}