<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jolution</title>
    <description>The latest articles on DEV Community by Jolution (@jolution).</description>
    <link>https://dev.to/jolution</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F88204%2F32dc7e6e-44c6-4182-929c-febfc49eb3ba.png</url>
      <title>DEV Community: Jolution</title>
      <link>https://dev.to/jolution</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jolution"/>
    <language>en</language>
    <item>
      <title>How to create favicons for darkmode (English) 🌚</title>
      <dc:creator>Jolution</dc:creator>
      <pubDate>Tue, 15 Mar 2022 15:24:27 +0000</pubDate>
      <link>https://dev.to/jolution/how-to-create-favicons-for-darkmode-english-46j8</link>
      <guid>https://dev.to/jolution/how-to-create-favicons-for-darkmode-english-46j8</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is also available in &lt;a href="https://dev.to/jolution/wie-man-favicons-fur-den-darkmode-erstellt-de-1nn2"&gt;German&lt;/a&gt; 🇩🇪&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Motives&lt;/li&gt;
&lt;li&gt;Requirement&lt;/li&gt;
&lt;li&gt;Create basics&lt;/li&gt;
&lt;li&gt;
Integration

&lt;ul&gt;
&lt;li&gt;Path&lt;/li&gt;
&lt;li&gt;Files&lt;/li&gt;
&lt;li&gt;
WordPress

&lt;ul&gt;
&lt;li&gt;Optional: Admin Favicon&lt;/li&gt;
&lt;li&gt;Fun: Emoji Favicon&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Typo3&lt;/li&gt;
&lt;li&gt;Static&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Darkmode&lt;/li&gt;
&lt;li&gt;
Fallback

&lt;ul&gt;
&lt;li&gt;Safari&lt;/li&gt;
&lt;li&gt;Other browsers&lt;/li&gt;
&lt;li&gt;
Future Prospects

&lt;ul&gt;
&lt;li&gt;Manifest color definition&lt;/li&gt;
&lt;li&gt;PWA / Maskable Icons&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Credits&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Motives
&lt;/h2&gt;

&lt;p&gt;👋🏼 Hello World,&lt;/p&gt;

&lt;p&gt;my name is &lt;a href="https://www.linkedin.com/in/julian-kasimir/"&gt;Julian&lt;/a&gt;. I'm a web developer, and I'm currently working more and more with darkmode.&lt;/p&gt;

&lt;p&gt;The topic is about the adaptation of favicons.&lt;br&gt;
Since I work a lot with WordPress, the integration is also thematized.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirement
&lt;/h2&gt;

&lt;p&gt;Since Firefox version 41 (2015) and &lt;a href="https://chromestatus.com/feature/5180316371124224"&gt;Chrome version 80&lt;/a&gt; (2019), we can use SVG favicons.&lt;br&gt;
However, there is no support in Safari yet.&lt;/p&gt;

&lt;p&gt;For requirements, see Caniuse.com's browser support on the following topics:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://caniuse.com/?search=SVG%20favicons"&gt;SVG favicons in the browser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://caniuse.com/?search=prefers-color-scheme"&gt;CSS Media Querie prefers-color-scheme&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c37pbOS2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qv51umhpnz3zq9mbnd63.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c37pbOS2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qv51umhpnz3zq9mbnd63.jpg" alt="Caniuse: https://caniuse.com/?search=SVG%20favicons" width="700" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create basics
&lt;/h2&gt;

&lt;p&gt;As source file I have my developer logo as SVG for maximum scalability and optimal performance.&lt;/p&gt;

&lt;p&gt;Otherwise, an image (PNG, JPG) with the size of 260x260 pixels for best results.&lt;/p&gt;

&lt;p&gt;From this we now export the following five formats and sizes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Filename&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;favicon.ico&lt;/td&gt;
&lt;td&gt;32×32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;favicon.svg&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;apple-touch-icon.png&lt;/td&gt;
&lt;td&gt;180×180&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;icon-192.png&lt;/td&gt;
&lt;td&gt;192x192&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;icon-512.png&lt;/td&gt;
&lt;td&gt;512x512&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I generate most of the files via the online service &lt;a href="https://realfavicongenerator.net"&gt;RealFaviconGenerator&lt;/a&gt;. I have left settings for this on the default.&lt;/p&gt;

&lt;p&gt;But of course you can use other graphic programs and export the formats like .ico with the help of extensions.&lt;br&gt;
&lt;em&gt;If an icon does not come along or needs to be readjusted, you can of course export it separately as a file from Illustrator.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;If you have Inkscape at hand, you can also just &lt;a href="https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs"&gt;generate&lt;/a&gt; it directly from the Console.:&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inkscape ./icon.svg --export-width=512 --export-filename="./icon-512.png"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now the following files should be available, which we load (e.g. via sFTP) into the document root of the page:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;│   └── public
|       ├── favicon.ico
|       ├── favicon.svg
|       ├── apple-touch-icon.png
|       ├── icon-192.png
|       ├── icon-512.png

|       ├── manifest.webmanifest    (see next paragraph)
|       ├── favicon_admin.svg       (optional: see next paragraph)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;The specification sizes="any" is currently important, because in Chrome &lt;a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1162276"&gt;instead of the svg the ico file&lt;/a&gt; is dragged.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Integration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Path
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The documentroot is suitable as the storage path for the icons.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This has the advantage that favicon.ico can also be used, even if no HTML is used: Example for this, would be files, like &lt;a href="https://stackoverflow.com/questions/4886423/display-favicon-for-pdf-files"&gt;a PDF file that is opened in the browser&lt;/a&gt;, or &lt;a href="https://stackoverflow.com/questions/21359342/is-putting-your-favicon-ico-file-in-a-non-root-path-a-bad-idea"&gt;images&lt;/a&gt;.&lt;br&gt;
If this is not possible, you could provide a redirect.&lt;/p&gt;

&lt;h3&gt;
  
  
  Files
&lt;/h3&gt;

&lt;p&gt;Manifest file to upload:&lt;/p&gt;

&lt;p&gt;Filename: manifest.webmanifest&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "name": "Jolution",
    "short_name": "Jolution",
    "icons": [
        { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
        { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
    ],
    "theme_color": "#292c2f",
    "background_color": "#292c2f",
    "display": "standalone"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Alternative with the minimum specifications:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "icons": [
        { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
        { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  WordPress
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// favicon frontend
add_action('wp_head', 'custom_favicon');
function custom_favicon() {
    echo '&amp;lt;link rel="icon" href="/favicon.ico" sizes="any"&amp;gt;';
    echo '&amp;lt;link rel="icon" href="/favicon.svg" type="image/svg+xml"&amp;gt;';
    echo '&amp;lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&amp;gt;';
    echo '&amp;lt;link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials"&amp;gt;';
    echo '&amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;';
    echo '&amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Alternatively, we can make it a line here or &lt;a href="https://www.php.net/manual/en/language.operators.string.php"&gt;concatenate&lt;/a&gt; (concatenation):&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_action('wp_head', 'custom_favicon');
function custom_favicon() {
    echo '&amp;lt;link rel="icon" href="/favicon.ico" sizes="any"&amp;gt;&amp;lt;link rel="icon" href="/favicon.svg" type="image/svg+xml"&amp;gt;&amp;lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&amp;gt;&amp;lt;link rel="manifest" href="/manifest.webmanifest"&amp;gt;&amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;&amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Optional: Admin Favicon
&lt;/h4&gt;

&lt;p&gt;As a little goodie to make it easier to differentiate between frontend and backend tabs in Chrome, i have a separate favicon located in the theme.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// favicon backend
add_action('login_head', 'custom_favicon_admin');
add_action('admin_head', 'custom_favicon_admin');
function custom_favicon_admin() {
    printf('&amp;lt;link rel="icon" href="%s/favicon_admin.svg" type="image/svg+xml"&amp;gt;', get_stylesheet_directory_uri());
    echo '&amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;';
    echo '&amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;If you don't have write-access to the document root and need to put the files in the theme, then you can use the printf statement above instead of echo.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you also have the admin-icon in the document root, then you don't need &lt;code&gt;get_stylesheet_directory_uri()&lt;/code&gt; and can work directly with /favicon_admin.svg:&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo '&amp;lt;link rel="icon" href="/favicon_admin.svg" type="image/svg+xml"&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Fun: Emoji Favicon
&lt;/h4&gt;

&lt;p&gt;If you like emojis, you can alternatively work with these, see the tweet by &lt;a href="https://twitter.com/LeaVerou/status/1241619866475474946"&gt;LeaVerou&lt;/a&gt;,&lt;br&gt;
and the online services for this, &lt;a href="https://emojicon.dev/"&gt;emojicon.dev&lt;/a&gt; and &lt;a href="https://fav.farm/"&gt;fav.farm&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'&amp;gt;&amp;lt;text x='0' y='14'&amp;gt;🌶&amp;lt;/text&amp;gt;&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Typo3
&lt;/h3&gt;

&lt;p&gt;Important: Before including the following code, check that the number (=position) 20 is not already assigned and will thus be overwritten.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If there is already position 20 in your &lt;a href="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/UsingSetting/Index.html"&gt;TypoScript&lt;/a&gt;, then it is best to check in &lt;a href="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#setup-page-1-2-3-4"&gt;increments of 10&lt;/a&gt; if 10 or 30 is free.&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;headerData {
    20 = TEXT
    20 {
        value (
            &amp;lt;link rel="icon" href="/favicon.ico" sizes="any"&amp;gt;
            &amp;lt;link rel="icon" href="/favicon.svg" type="image/svg+xml"&amp;gt;
            &amp;lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&amp;gt;
            &amp;lt;link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials"&amp;gt;
            &amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;
            &amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;
        )
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Currently, the &lt;strong&gt;alternative embedding option&lt;/strong&gt; &lt;a href="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#shortcuticon"&gt;&lt;code&gt;shortcutIcon&lt;/code&gt;&lt;/a&gt; allows only one icon:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;page.shortcutIcon = fileadmin/Icons/favicon.ico
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The meta information theme-color in the upper part, can not (currently) be included via &lt;a href="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#meta"&gt;&lt;code&gt;page.meta&lt;/code&gt;&lt;/a&gt;, because no media query can be integrated here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Static
&lt;/h3&gt;

&lt;p&gt;In the head of the web page we put the following HTML code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;

  &amp;lt;link rel="icon" href="/favicon.ico" sizes="any"&amp;gt;
  &amp;lt;link rel="icon" href="/favicon.svg" type="image/svg+xml"&amp;gt;
  &amp;lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&amp;gt;
  &amp;lt;link rel="manifest" href="/manifest.webmanifest"&amp;gt;

  &amp;lt;title&amp;gt;Example&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Optionally, the theme-color can also be included above the title:&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;
&amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Instead of content="#fff", &lt;a href="https://css-tricks.com/meta-theme-color-and-trickery/"&gt;CSS-variables&lt;/a&gt; can also be used here.&lt;br&gt;
&lt;em&gt;The variables in this example are from TailwindCSS.&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo '&amp;lt;meta name="theme-color" content="var(--teal-800)" media="(prefers-color-scheme: light)"&amp;gt;';
echo '&amp;lt;meta name="theme-color" content="var(--white)" media="(prefers-color-scheme: dark)"&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Darkmode
&lt;/h2&gt;

&lt;p&gt;Since SVG is now well-supported by the major browsers, I'll focus only on the SVG file.&lt;/p&gt;

&lt;p&gt;With a text program we open it and look at it.&lt;br&gt;
An SVG file can get very large depending on the logo.&lt;br&gt;
You could try to reduce this already in the vector program.&lt;br&gt;
Additionally, you can compress the file with &lt;a href="https://jakearchibald.github.io/svgomg/"&gt;SVGOMG&lt;/a&gt; or other &lt;a href="https://css-tricks.com/tools-for-optimizing-svg/"&gt;tools for Optimizing SVG&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important: Make a backup of the original file before.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My &lt;a href="https://jolution.de/"&gt;developer logo&lt;/a&gt; is a J in a circle.&lt;br&gt;
I exported this as one path, but this is of course not a must. Of course, multiple paths can be addressed.&lt;br&gt;
I have assigned a dark color to the path by default.&lt;br&gt;
If the darkmode is detected, the same path is defined with a white color.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expected result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Darkmode: Ⓙ&lt;/p&gt;

&lt;p&gt;Lightmode: 🅙&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg version="1.1" baseProfile="full" width="400" height="400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"&amp;gt;
&amp;lt;path d="M200 0A200 200 0 0 0 0 200a200 200 0 0 0 200 200 200 200 0 0 0 200-200 200 200 0 0 0-76.736-157.21l-.028 156.01c0 4.268-.214 8.484-.636 12.64-.422 4.155-1.05 8.25-1.873 12.273-.824 4.023-1.843 7.975-3.047 11.846-1.204 3.87-2.593 7.66-4.157 11.356-1.563 3.697-3.302 7.302-5.205 10.805-1.903 3.504-3.97 6.904-6.19 10.192-2.222 3.288-4.6 6.463-7.118 9.516-2.52 3.052-5.18 5.98-7.977 8.777-2.796 2.796-5.727 5.46-8.78 7.98-3.052 2.518-6.227 4.892-9.515 7.114-3.288 2.22-6.688 4.29-10.19 6.192-3.504 1.903-7.11 3.642-10.806 5.205-3.697 1.564-7.487 2.953-11.357 4.157-3.87 1.203-7.823 2.22-11.846 3.044-4.024.824-8.12 1.45-12.274 1.873-4.156.423-8.372.64-12.64.64-3.914-.005-7.81-.195-11.677-.566-3.867-.372-7.703-.924-11.497-1.653-3.794-.727-7.545-1.633-11.242-2.71-3.696-1.076-7.34-2.324-10.917-3.74-3.577-1.415-7.088-2.997-10.52-4.742-3.435-1.744-6.79-3.65-10.054-5.715-3.267-2.064-6.443-4.285-9.517-6.66s-6.046-4.903-8.904-7.578l28.102-38.64s1.317 1.547 3.84 3.868c1.262 1.16 2.824 2.516 4.676 3.967 1.852 1.452 3.993 3 6.408 4.55 2.415 1.548 5.104 3.096 8.055 4.548 2.952 1.452 6.164 2.808 9.624 3.97 3.46 1.163 7.167 2.133 11.11 2.813 1.97.34 4 .61 6.087.792 2.088.183 4.23.28 6.43.283 2.636 0 5.24-.128 7.81-.38 2.568-.25 5.097-.622 7.583-1.112 2.487-.49 4.93-1.095 7.323-1.812 2.392-.716 4.732-1.545 7.017-2.478 2.285-.933 4.513-1.97 6.678-3.11 2.166-1.137 4.268-2.375 6.3-3.706 2.032-1.332 3.994-2.758 5.88-4.272 1.887-1.513 3.698-3.113 5.427-4.797 1.728-1.684 3.372-3.452 4.93-5.295 1.556-1.843 3.025-3.76 4.398-5.752 1.372-1.99 2.65-4.052 3.826-6.18 1.177-2.126 2.25-4.318 3.218-6.57.966-2.25 1.824-4.562 2.568-6.927.744-2.365 1.374-4.785 1.883-7.252.508-2.466.896-4.983 1.157-7.54.26-2.558.395-5.156.395-7.793l.015-147.084-.045-38.035A200 200 0 0 0 200 0z"&amp;gt;
&amp;lt;/path&amp;gt;
&amp;lt;style&amp;gt;
    path {
        fill: #22343b
    }
    @media (prefers-color-scheme: dark) {
        path{
            fill: #fff
        }
    }
&amp;lt;/style&amp;gt;
&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Alternatively, instead of changing the color, you can also change the brightness.&lt;br&gt;
Depending on the effort (amount of path adjustments) this can also be a solution.&lt;br&gt;
&lt;em&gt;Personally, however, I prefer the simple color adjustment.&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (prefers-color-scheme: dark) {
  :root {
    filter: brightness(4);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://codepen.io/jolution/pen/bGadeQY"&gt;https://codepen.io/jolution/pen/bGadeQY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you now want to add as meta theme-color, this is also easily &lt;a href="https://css-tricks.com/meta-theme-color-and-trickery/"&gt;doable&lt;/a&gt;:&lt;br&gt;
    &lt;br&gt;
    &lt;/p&gt;

&lt;h2&gt;
  
  
  Fallback
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Safari
&lt;/h3&gt;

&lt;p&gt;Safari unfortunately does not yet support the automatically detectable darkmode.&lt;br&gt;
The normal toggle functions would of course be &lt;a href="https://www.w3schools.com/howto/howto_js_toggle_dark_mode.asp"&gt;no problem&lt;/a&gt; here.&lt;br&gt;
&lt;em&gt;When I have found a solution, I will of course update the article.&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="mask-icon" href="favicon.svg" color="#22343b"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Feel free to write me in the comments if you have a good and easy approach to this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Other browsers
&lt;/h3&gt;

&lt;p&gt;Since not all browsers support the media query features in the link tag, this &lt;a href="https://github.com/rumkin/favicon-switcher"&gt;polyfill&lt;/a&gt; fixes that.&lt;br&gt;
However, JS is used here, so I would weigh the use and if in doubt, do without it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can use the favicon checker from realfavicongenerator to &lt;a href="https://realfavicongenerator.net/favicon_checker?protocol=https&amp;amp;site=jolution.de#.Yi9ZJrgxlzV"&gt;check&lt;/a&gt; the usage afterwards.&lt;/em&gt;&lt;br&gt;
If a browser is missing for your taste, add the meta information from the generator and load the appropriate files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Future Prospects
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Manifest color definition
&lt;/h4&gt;

&lt;p&gt;For some cases it would be ideal to already specify colors for both modes in the manifest.&lt;br&gt;
If you are already interested in this, you can find &lt;a href="https://github.com/w3c/manifest/issues?q=is%3Aissue+is%3Aopen+%22dark+mode%22"&gt;further information as well as the exchange&lt;/a&gt; at github in English.&lt;/p&gt;

&lt;h4&gt;
  
  
  PWA / Maskable Icons
&lt;/h4&gt;

&lt;p&gt;At &lt;a href="https://web.dev/maskable-icon/?utm_source=devtools"&gt;web.dev&lt;/a&gt; there is a 2019 approach to the topic of PWA on the topic of "maskable icons".&lt;/p&gt;

&lt;h2&gt;
  
  
  Credits
&lt;/h2&gt;

&lt;p&gt;Thanks to Andrey Sitnik (author of PostCSS and Autoprefixer) who gathered the above measurements as &lt;a href="https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs"&gt;optimal set&lt;/a&gt;.&lt;br&gt;
And also to Houssein Djirdeh (Software Engineer at @GoogleChrome) who also &lt;a href="https://web.dev/add-manifest-react/"&gt;uses&lt;/a&gt; these specifications with 512x512.&lt;/p&gt;

&lt;p&gt;Good luck and have fun with the implementation.&lt;/p&gt;

</description>
      <category>darkmode</category>
      <category>wordpress</category>
      <category>favicon</category>
      <category>translated</category>
    </item>
    <item>
      <title>Wie man Favicons für den Darkmode erstellt (German) 🌚</title>
      <dc:creator>Jolution</dc:creator>
      <pubDate>Tue, 15 Mar 2022 11:42:15 +0000</pubDate>
      <link>https://dev.to/jolution/wie-man-favicons-fur-den-darkmode-erstellt-de-1nn2</link>
      <guid>https://dev.to/jolution/wie-man-favicons-fur-den-darkmode-erstellt-de-1nn2</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Dieser Artikel ist auch in &lt;a href="https://dev.to/jolution/how-to-create-favicons-for-darkmode-english-46j8"&gt;Englisch&lt;/a&gt; verfügbar 🇬🇧&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Beweggründe&lt;/li&gt;
&lt;li&gt;Voraussetzung&lt;/li&gt;
&lt;li&gt;Grundlagen erstellen&lt;/li&gt;
&lt;li&gt;
Einbindung

&lt;ul&gt;
&lt;li&gt;Pfad&lt;/li&gt;
&lt;li&gt;Dateien&lt;/li&gt;
&lt;li&gt;
WordPress

&lt;ul&gt;
&lt;li&gt;Optional: Admin Favicon&lt;/li&gt;
&lt;li&gt;Fun: Emoji Favicon&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Typo3&lt;/li&gt;

&lt;li&gt;Static&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;Darkmode&lt;/li&gt;

&lt;li&gt;

Fallback

&lt;ul&gt;
&lt;li&gt;Safari&lt;/li&gt;
&lt;li&gt;Andere Browser&lt;/li&gt;
&lt;li&gt;
Aussichten

&lt;ul&gt;
&lt;li&gt;Manifest Farbdefinition&lt;/li&gt;
&lt;li&gt;PWA / Maskable Icons&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;Credits&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Beweggründe
&lt;/h2&gt;

&lt;p&gt;👋🏼 Hello World,&lt;/p&gt;

&lt;p&gt;mein Name ist &lt;a href="https://www.linkedin.com/in/julian-kasimir/" rel="noopener noreferrer"&gt;Julian&lt;/a&gt;. Ich bin Webentwickler und setze mich beruflich aktuell vermehrt mit dem Darkmode auseinander.&lt;/p&gt;

&lt;p&gt;Das Thema handelt über die Anpassung der Favicons.&lt;br&gt;
Da ich viel mit Wordpress arbeite, wird auch die Einbindung thematisiert.&lt;/p&gt;

&lt;h2&gt;
  
  
  Voraussetzung
&lt;/h2&gt;

&lt;p&gt;Seit der Firefox Version 41 (2015) und der &lt;a href="https://chromestatus.com/feature/5180316371124224" rel="noopener noreferrer"&gt;Chrome Version 80&lt;/a&gt; (2019) können wir SVG-Favicons nutzen.&lt;br&gt;
In Safari gibt es allerdings noch keinen Support.&lt;/p&gt;

&lt;p&gt;Zu den Voraussetzungen siehe hierzu den Browser-Support von Caniuse.com zu folgenden Themen:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://caniuse.com/?search=SVG%20favicons" rel="noopener noreferrer"&gt;SVG Favicons im Browser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://caniuse.com/?search=prefers-color-scheme" rel="noopener noreferrer"&gt;CSS Media Querie prefers-color-scheme&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqv51umhpnz3zq9mbnd63.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqv51umhpnz3zq9mbnd63.jpg" alt="Caniuse: https://caniuse.com/?search=SVG%20favicons"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Grundlagen erstellen
&lt;/h2&gt;

&lt;p&gt;Als Ausgangsdatei habe ich für maximale Skalierbarkeit und optimale Performance mein Entwickler-Logo als SVG vorliegen.&lt;/p&gt;

&lt;p&gt;Andernfalls ein Bild (PNG, JPG) mit der Größe von 260x260 Pixeln für optimale Ergebnisse.&lt;/p&gt;

&lt;p&gt;Daraus exportieren wir nun folgende fünf Formate und Größen:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Datei&lt;/th&gt;
&lt;th&gt;Größe&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;favicon.ico&lt;/td&gt;
&lt;td&gt;32×32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;favicon.svg&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;apple-touch-icon.png&lt;/td&gt;
&lt;td&gt;180×180&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;icon-192.png&lt;/td&gt;
&lt;td&gt;192x192&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;icon-512.png&lt;/td&gt;
&lt;td&gt;512x512&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Die Dateien generiere ich über den Onlinedienst &lt;a href="https://realfavicongenerator.net" rel="noopener noreferrer"&gt;RealFaviconGenerator&lt;/a&gt;. Einstellungen habe ich hierfür auf der Standardausführung gelassen.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Du kannst natürlich aber auch andere Grafikprogramme nutzen und mithilfe von Erweiterungen die Formate wie .ico exportieren.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Sollte ein Icon nicht mitkommen oder nachjustiert werden müssen, kann man es natürlich auch gesondert als Datei aus Illustrator exportieren.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Wenn du Inkscape zur Hand hast, kannst du es auch einfach direkt über die Console &lt;a href="https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs" rel="noopener noreferrer"&gt;generieren&lt;/a&gt;:&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inkscape ./icon.svg --export-width=512 --export-filename="./icon-512.png"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Nun sollten folgende Dateien vorliegen, welche wir (bspw. per sFTP) in den Dokument Root der Seite laden:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;│   └── public
|       ├── favicon.ico
|       ├── favicon.svg
|       ├── apple-touch-icon.png
|       ├── icon-192.png
|       ├── icon-512.png

|       ├── manifest.webmanifest    (Siehe hierzu nächster Abschnitt)
|       ├── favicon_admin.svg       (Optional: Siehe hierzu nächster Abschnitt)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Die Angabe sizes="any" ist aktuell wichtig, da in Chrome &lt;a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1162276" rel="noopener noreferrer"&gt;statt dem svg die ico Datei&lt;/a&gt; gezogen wird.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Einbindung
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pfad
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Als Ablagepfad für die Icons eignet sich der Documentroot.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dies hat den Vorteil das, dass favicon.ico ebenfalls zum Einsatz kommen kann, wenn auch kein HTML verwendet wird: Beispiel hierfür, wären Dateien, wie &lt;a href="https://stackoverflow.com/questions/4886423/display-favicon-for-pdf-files" rel="noopener noreferrer"&gt;eine PDF Datei die im Browser geöffnet wird&lt;/a&gt;, oder &lt;a href="https://stackoverflow.com/questions/21359342/is-putting-your-favicon-ico-file-in-a-non-root-path-a-bad-idea" rel="noopener noreferrer"&gt;Bilder&lt;/a&gt;.&lt;br&gt;
&lt;em&gt;Falls dies nicht möglich ist, könnte man hier einen Redirect vorsehen.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Dateien
&lt;/h3&gt;

&lt;p&gt;Manifest-Datei zum Hochladen:&lt;/p&gt;

&lt;p&gt;Dateiname: manifest.webmanifest&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "name": "Jolution",
    "short_name": "Jolution",
    "icons": [
        { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
        { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
    ],
    "theme_color": "#292c2f",
    "background_color": "#292c2f",
    "display": "standalone"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Alternative mit den Minimum-Angaben:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "icons": [
        { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
        { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  WordPress
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// favicon frontend
add_action('wp_head', 'custom_favicon');
function custom_favicon() {
    echo '&amp;lt;link rel="icon" href="/favicon.ico" sizes="any"&amp;gt;';
    echo '&amp;lt;link rel="icon" href="/favicon.svg" type="image/svg+xml"&amp;gt;';
    echo '&amp;lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&amp;gt;';
    echo '&amp;lt;link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials"&amp;gt;';
    echo '&amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;';
    echo '&amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Alternativ können wir hier auch eine Zeile daraus machen oder &lt;a href="https://www.php.net/manual/en/language.operators.string.php" rel="noopener noreferrer"&gt;verketten&lt;/a&gt; (concatenation):&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_action('wp_head', 'custom_favicon');
function custom_favicon() {
    echo '&amp;lt;link rel="icon" href="/favicon.ico" sizes="any"&amp;gt;&amp;lt;link rel="icon" href="/favicon.svg" type="image/svg+xml"&amp;gt;&amp;lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&amp;gt;&amp;lt;link rel="manifest" href="/manifest.webmanifest"&amp;gt;&amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;&amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Optional: Admin Favicon
&lt;/h4&gt;

&lt;p&gt;Als kleines Goodie, um einfacher zwischen Frontend und Backend Tabs in Chrome zu unterscheiden, habe ich im Theme eine gesonderte Favicon liegen:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// favicon backend
add_action('login_head', 'custom_favicon_admin');
add_action('admin_head', 'custom_favicon_admin');
function custom_favicon_admin() {
    printf('&amp;lt;link rel="icon" href="%s/favicon_admin.svg" type="image/svg+xml"&amp;gt;', get_stylesheet_directory_uri());
    echo '&amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;';
    echo '&amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Solltest du kein Schreibzugriff auf den Documentroot haben und die Dateien in das Theme legen müssen, dann kannst du statt echo die printf Anweisung oben verwenden.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Wenn du das Admin-Icon ebenfalls im Document Root liegen hast, dann benötigst du &lt;code&gt;get_stylesheet_directory_uri()&lt;/code&gt; nicht und kannst direkt mit /favicon_admin.svg arbeiten:&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo '&amp;lt;link rel="icon" href="/favicon_admin.svg" type="image/svg+xml"&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Fun: Emoji Favicon
&lt;/h4&gt;

&lt;p&gt;Wer Emojis mag, kann alternativ auch mit diesen arbeiten, siehe hierzu den Tweet von &lt;a href="https://twitter.com/LeaVerou/status/1241619866475474946" rel="noopener noreferrer"&gt;LeaVerou&lt;/a&gt;,&lt;br&gt;
sowie die Online-Dienste hierzu, &lt;a href="https://emojicon.dev/" rel="noopener noreferrer"&gt;emojicon.dev&lt;/a&gt; und &lt;a href="https://fav.farm/" rel="noopener noreferrer"&gt;fav.farm&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'&amp;gt;&amp;lt;text x='0' y='14'&amp;gt;🌶&amp;lt;/text&amp;gt;&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Typo3
&lt;/h3&gt;

&lt;p&gt;Wichtig: Vor dem Einbinden des folgenden Codes prüfen, dass die Zahl (=Position) 20 nicht schon vergeben ist und somit überschrieben wird.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Falls es bereits die Position 20 in Ihrem &lt;a href="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/UsingSetting/Index.html" rel="noopener noreferrer"&gt;TypoScript&lt;/a&gt; gibt, dann prüfen Sie am besten in &lt;a href="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#setup-page-1-2-3-4" rel="noopener noreferrer"&gt;10er Schritten&lt;/a&gt;, ob die 10 oder 30 frei ist.&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;headerData {
    20 = TEXT
    20 {
        value (
            &amp;lt;link rel="icon" href="/favicon.ico" sizes="any"&amp;gt;
            &amp;lt;link rel="icon" href="/favicon.svg" type="image/svg+xml"&amp;gt;
            &amp;lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&amp;gt;
            &amp;lt;link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials"&amp;gt;
            &amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;
            &amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;
        )
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Aktuell lässt die &lt;strong&gt;alternative Einbindungsmöglichkeit&lt;/strong&gt; &lt;a href="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#shortcuticon" rel="noopener noreferrer"&gt;&lt;code&gt;shortcutIcon&lt;/code&gt;&lt;/a&gt; nur ein Icon zu:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;page.shortcutIcon = fileadmin/Icons/favicon.ico
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Die Meta-Angaben theme-color im oberen Teil, lässt sich (aktuell) leider nicht über &lt;a href="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#meta" rel="noopener noreferrer"&gt;&lt;code&gt;page.meta&lt;/code&gt;&lt;/a&gt; einbinden, da hier kein media Abfrage integriert werden kann.&lt;/p&gt;

&lt;h3&gt;
  
  
  Static
&lt;/h3&gt;

&lt;p&gt;In den Head der Webseite packen wir nun folgenden HTML Code:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;

  &amp;lt;link rel="icon" href="/favicon.ico" sizes="any"&amp;gt;
  &amp;lt;link rel="icon" href="/favicon.svg" type="image/svg+xml"&amp;gt;
  &amp;lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&amp;gt;
  &amp;lt;link rel="manifest" href="/manifest.webmanifest"&amp;gt;

  &amp;lt;title&amp;gt;Example&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Optional kann auch zusätzlich, oberhalb des title, die theme-color eingebunden werden:&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta name="theme-color" content="#22343b" media="(prefers-color-scheme: light)"&amp;gt;
&amp;lt;meta name="theme-color" content="#fff" media="(prefers-color-scheme: dark)"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Statt content="#fff" kann hier auch auf &lt;a href="https://css-tricks.com/meta-theme-color-and-trickery/" rel="noopener noreferrer"&gt;CSS-Variablen&lt;/a&gt; gesetzt werden.&lt;br&gt;
&lt;em&gt;Die Variablen in diesem Beispiel stammen von TailwindCSS.&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo '&amp;lt;meta name="theme-color" content="var(--teal-800)" media="(prefers-color-scheme: light)"&amp;gt;';
echo '&amp;lt;meta name="theme-color" content="var(--white)" media="(prefers-color-scheme: dark)"&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Darkmode
&lt;/h2&gt;

&lt;p&gt;Da SVG mittlerweile von den großen Browsern gut unterstützt wird, konzentriere ich mich nur auf die SVG-Datei.&lt;/p&gt;

&lt;p&gt;Mit einem Textprogramm öffnen wir diese und schauen uns diese an.&lt;br&gt;
Eine SVG-Datei kann je nach Logo sehr groß werden.&lt;br&gt;
Du könntest versuchen dies bereits im Vektorenprogramm zu reduzieren.&lt;br&gt;
Zusätzlich kannst du mit &lt;a href="https://jakearchibald.github.io/svgomg/" rel="noopener noreferrer"&gt;SVGOMG&lt;/a&gt; oder anderen &lt;a href="https://css-tricks.com/tools-for-optimizing-svg/" rel="noopener noreferrer"&gt;Diensten zur Optimierung&lt;/a&gt; die SVG-Datei komprimieren.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wichtig: Vorher ein Backup der Originaldatei erstellen.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mein &lt;a href="https://jolution.de/" rel="noopener noreferrer"&gt;Entwickler-Logo&lt;/a&gt; ist ein J in einem Kreis.&lt;br&gt;
Dies habe ich als ein Pfad exportiert, dass ist aber natürlich kein Muss. Natürlich können auch mehrere Pfade angesprochen werden.&lt;br&gt;
Dem Pfad habe ich nun standardmäßig eine dunkle Farbe zugewiesen.&lt;br&gt;
Wird der Darkmode erkannt, wird der gleiche Pfad mit einer weißen Farbe definiert.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Erwartetes Resultat:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Darkmode: Ⓙ&lt;/p&gt;

&lt;p&gt;Lightmode: 🅙&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg version="1.1" baseProfile="full" width="400" height="400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"&amp;gt;
&amp;lt;path d="M200 0A200 200 0 0 0 0 200a200 200 0 0 0 200 200 200 200 0 0 0 200-200 200 200 0 0 0-76.736-157.21l-.028 156.01c0 4.268-.214 8.484-.636 12.64-.422 4.155-1.05 8.25-1.873 12.273-.824 4.023-1.843 7.975-3.047 11.846-1.204 3.87-2.593 7.66-4.157 11.356-1.563 3.697-3.302 7.302-5.205 10.805-1.903 3.504-3.97 6.904-6.19 10.192-2.222 3.288-4.6 6.463-7.118 9.516-2.52 3.052-5.18 5.98-7.977 8.777-2.796 2.796-5.727 5.46-8.78 7.98-3.052 2.518-6.227 4.892-9.515 7.114-3.288 2.22-6.688 4.29-10.19 6.192-3.504 1.903-7.11 3.642-10.806 5.205-3.697 1.564-7.487 2.953-11.357 4.157-3.87 1.203-7.823 2.22-11.846 3.044-4.024.824-8.12 1.45-12.274 1.873-4.156.423-8.372.64-12.64.64-3.914-.005-7.81-.195-11.677-.566-3.867-.372-7.703-.924-11.497-1.653-3.794-.727-7.545-1.633-11.242-2.71-3.696-1.076-7.34-2.324-10.917-3.74-3.577-1.415-7.088-2.997-10.52-4.742-3.435-1.744-6.79-3.65-10.054-5.715-3.267-2.064-6.443-4.285-9.517-6.66s-6.046-4.903-8.904-7.578l28.102-38.64s1.317 1.547 3.84 3.868c1.262 1.16 2.824 2.516 4.676 3.967 1.852 1.452 3.993 3 6.408 4.55 2.415 1.548 5.104 3.096 8.055 4.548 2.952 1.452 6.164 2.808 9.624 3.97 3.46 1.163 7.167 2.133 11.11 2.813 1.97.34 4 .61 6.087.792 2.088.183 4.23.28 6.43.283 2.636 0 5.24-.128 7.81-.38 2.568-.25 5.097-.622 7.583-1.112 2.487-.49 4.93-1.095 7.323-1.812 2.392-.716 4.732-1.545 7.017-2.478 2.285-.933 4.513-1.97 6.678-3.11 2.166-1.137 4.268-2.375 6.3-3.706 2.032-1.332 3.994-2.758 5.88-4.272 1.887-1.513 3.698-3.113 5.427-4.797 1.728-1.684 3.372-3.452 4.93-5.295 1.556-1.843 3.025-3.76 4.398-5.752 1.372-1.99 2.65-4.052 3.826-6.18 1.177-2.126 2.25-4.318 3.218-6.57.966-2.25 1.824-4.562 2.568-6.927.744-2.365 1.374-4.785 1.883-7.252.508-2.466.896-4.983 1.157-7.54.26-2.558.395-5.156.395-7.793l.015-147.084-.045-38.035A200 200 0 0 0 200 0z"&amp;gt;
&amp;lt;/path&amp;gt;
&amp;lt;style&amp;gt;
    path {
        fill: #22343b
    }
    @media (prefers-color-scheme: dark) {
        path{
            fill: #fff
        }
    }
&amp;lt;/style&amp;gt;
&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Alternativ kannst du statt einer Farbänderung auch die Helligkeit verändern.&lt;br&gt;
Das kann je nach Aufwand (Menge der Pfadanpassungen) auch eine Lösung sein.&lt;br&gt;
&lt;em&gt;Ich persönlich bevorzuge allerdings die einfache Farbanpassung.&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (prefers-color-scheme: dark) {
  :root {
    filter: brightness(4);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://codepen.io/jolution/pen/bGadeQY" rel="noopener noreferrer"&gt;https://codepen.io/jolution/pen/bGadeQY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wenn du nun noch als Meta theme-color hinzufügen möchtest, ist dies auch einfach &lt;a href="https://css-tricks.com/meta-theme-color-and-trickery/" rel="noopener noreferrer"&gt;machbar&lt;/a&gt;:&lt;br&gt;
    &lt;br&gt;
    &lt;/p&gt;

&lt;h2&gt;
  
  
  Fallback
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Safari
&lt;/h3&gt;

&lt;p&gt;Safari unterstützt den automatisch erkennbaren Darkmode leider noch nicht.&lt;br&gt;
Die normalen Toggle-Funktionen wären hier natürlich &lt;a href="https://www.w3schools.com/howto/howto_js_toggle_dark_mode.asp" rel="noopener noreferrer"&gt;kein Problem&lt;/a&gt;.&lt;br&gt;
&lt;em&gt;Wenn ich eine Lösung gefunden habe, aktualisiere ich den Artikel natürlich.&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="mask-icon" href="favicon.svg" color="#22343b"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Schreibt mir gerne in die Kommentare, wenn Ihr einen guten und leichten Ansatz dafür habt.&lt;/p&gt;

&lt;h3&gt;
  
  
  Andere Browser
&lt;/h3&gt;

&lt;p&gt;Da nicht alle Browser die Medienabfragefunktionen im Link-Tag unterstützen, behebt dieses &lt;a href="https://github.com/rumkin/favicon-switcher" rel="noopener noreferrer"&gt;Polyfill&lt;/a&gt; dies.&lt;br&gt;
Hier wird allerdings JS verwendet, daher würde ich den Einsatz abwiegen und im Zweifelsfall darauf verzichten.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Mit dem Favicon checker von realfavicongenerator kann man den Einsatz anschließend &lt;a href="https://realfavicongenerator.net/favicon_checker?protocol=https&amp;amp;site=jolution.de#.Yi9ZJrgxlzV" rel="noopener noreferrer"&gt;prüfen&lt;/a&gt;.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Sollte für euren Geschmack noch ein Browser fehlen, ergänzt die Meta Angaben durch die von dem Generator und ladet die entsprechenden Dateien dazu.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Aussichten
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Manifest Farbdefinition
&lt;/h4&gt;

&lt;p&gt;Für manche Fälle wäre es ideal im Manifest bereits Farben für beide Modes anzugeben.&lt;br&gt;
Wer sich dafür jetzt schon interessiert, findet bei github auf Englisch &lt;a href="https://github.com/w3c/manifest/issues?q=is%3Aissue+is%3Aopen+%22dark+mode%22" rel="noopener noreferrer"&gt;weiterführende Informationen sowie den Austausch&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  PWA / Maskable Icons
&lt;/h4&gt;

&lt;p&gt;Bei &lt;a href="https://web.dev/maskable-icon/?utm_source=devtools" rel="noopener noreferrer"&gt;web.dev&lt;/a&gt; gibt es zu dem Thema PWA einen Ansatz von 2019 zum Thema "maskable icons".&lt;/p&gt;

&lt;h2&gt;
  
  
  Credits
&lt;/h2&gt;

&lt;p&gt;Danke an Andrey Sitnik (Autor von PostCSS und Autoprefixer) der die oben aufgeführten Maße als &lt;a href="https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs" rel="noopener noreferrer"&gt;optimales Set&lt;/a&gt; zusammengetragen hat.&lt;br&gt;
Und auch an Houssein Djirdeh (Software Engineer bei @GoogleChrome) der diese Angaben mit 512x512 ebenfalls &lt;a href="https://web.dev/add-manifest-react/" rel="noopener noreferrer"&gt;verwendet&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Viel Erfolg und Spaß bei der Umsetzung.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;P.s. Wenn dich das Thema Darkmode, ganz allgemein, interessiert, ist mein Artikel bei &lt;a href="https://jolution.medium.com/how-to-rock-the-darkmode-de-6a4c4540e5bc" rel="noopener noreferrer"&gt;Medium&lt;/a&gt; vielleicht Interessant für dich.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>darkmode</category>
      <category>wordpress</category>
      <category>favicon</category>
      <category>deutsch</category>
    </item>
  </channel>
</rss>
