diff --git a/exampleSite/content/basics/customization/_index.en.md b/exampleSite/content/basics/customization/_index.en.md index ce5df65efc..fe410796e8 100644 --- a/exampleSite/content/basics/customization/_index.en.md +++ b/exampleSite/content/basics/customization/_index.en.md @@ -43,7 +43,7 @@ The size of the logo will adapt automatically If your favicon is a SVG, PNG or ICO, just drop off your image in your local `static/images/` folder and name it `favicon.svg`, `favicon.png` or `favicon.ico` respectively. -Alternatively, if you want your site to use light & dark theme SVG favicons that follow the OS' (and in some cases, the browser's) color scheme, add the image files to your local `static/images/` folder and name them `favicon-light.svg` and `favicon-dark.svg` respectively. +Additionally, if you want your site to use light & dark theme favicons that follow the OS' (and in some cases, the browser's) color scheme, add the image files to your local `static/images/` folder and name them eg. `favicon-light.svg` and/or `favicon-dark.svg` respectively corresponding to your file format. In case one of the files is missing, the theme falls back to eg. `favicon.svg` for the missing file. All supplied favicons must be of the same file format. {{% notice warning %}} IE and old browser versions do not support [media queries](https://caniuse.com/css-media-interaction), which are necessary for the light & dark theme favicon option. diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index 62e6c0d90d..a2de2162b0 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -24,6 +24,8 @@ This document shows you what's new in the latest release. For a detailed list of Additionally the `name` parameter was renamed to `title`. You don't need to change anything yet as the old name will be used as a fallback but you will get deprecation warnings while executing Hugo. +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme now supports [separate favicons]({{%relref "basics/customization/#change-the-favicon" %}}) for light & dark mode optionally. + --- ## 5.15.0 (2023-05-29) diff --git a/layouts/partials/favicon.html b/layouts/partials/favicon.html index e11aa6fc31..ebb551add5 100644 --- a/layouts/partials/favicon.html +++ b/layouts/partials/favicon.html @@ -1,46 +1,32 @@ {{- $assetBusting := not .Site.Params.disableAssetsBusting }} {{- $faviconMatch := false }} - {{- $svg := dict "ext" "svg" "type" "image/svg+xml" }} - {{- $png := dict "ext" "png" "type" "image/png" }} - {{- $ico := dict "ext" "ico" "type" "image/x-icon" }} + {{- $svg := dict "ext" "svg" "type" "type=\"image/svg+xml\"" }} + {{- $png := dict "ext" "png" "type" "type=\"image/png\"" }} + {{- $ico := dict "ext" "ico" "type" "type=\"image/x-icon\" sizes=\"any\"" }} {{- $faviconTypes := slice $svg $png $ico }} - {{- range $faviconTypes }} - {{- if and - (eq $faviconMatch false) - (or - (fileExists (printf "/static/images/favicon-light.%s" .ext)) - (fileExists (printf "/static/images/favicon-dark.%s")) - ) - }} - {{- $faviconMatch = true }} - {{$c:=""}}{{/* + {{- $faviconNames := slice "favicon" "logo" }} + {{- range $faviconNames }} + {{- $faviconName := . }} + {{- range $faviconTypes }} + {{- if fileExists (printf "/static/images/%s.%s" $faviconName .ext) }} + {{- $faviconMatch = true }} + + {{- end }} + {{- $c:="" }}{{/* Warning: IE and old browser versions do not support media queries necessary for the light & dark theme option. If you have requirements to support IE and/or older browser versions, use one of the other options. Reference: https://caniuse.com/css-media-interaction */}} - {{- if (fileExists (printf "/static/images/favicon-light.%s" .ext)) }} - + {{- if (fileExists (printf "/static/images/%s-light.%s" $faviconName .ext)) }} + {{- $faviconMatch = true }} + {{- end }} - {{- if (fileExists (printf "/static/images/favicon-dark.%s" .ext)) }} - + {{- if (fileExists (printf "/static/images/%s-dark.%s" $faviconName .ext)) }} + {{- $faviconMatch = true }} + {{- end }} {{- end }} - {{- end }} - {{- range $faviconTypes }} - {{- if and - (eq $faviconMatch false) - (fileExists (printf "/static/images/favicon.%s" .ext)) - }} - {{- $faviconMatch = true }} - - {{- end }} - {{- end }} - {{- range $faviconTypes }} - {{- if and - (eq $faviconMatch false) - (fileExists (printf "/static/images/logo.%s" .ext)) - }} - {{- $faviconMatch := true }} - + {{- if $faviconMatch }} + {{- break }} {{- end }} {{- end }} \ No newline at end of file