How to do favicons on websites
Instead of serving dozens of icons, all you need is just five icons and one JSON file.
For the browser using HTML:
<link rel="icon" href="/favicon.ico" sizes="32x32" />
<link rel="icon" href="/icon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
If you’re making a PWA (Progressive Web App), also add this to the HTML:
<link rel="manifest" href="/manifest.webmanifest" />
And a file with the web app manifest:
// manifest.webmanifest
{
"icons": [
{ "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
{
"src": "/icon-mask.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
},
{ "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
]
}
Maskable icons should have bigger paddings. The safe zone is a 409×409 circle. Use maskable.app to check your icon.
That’s it. If you want to know how I got here, the compromises I had to make, and how to build a set like this from scratch in a step-by-step fashion, stay tuned in for the rest of the article.
No webmentions were found.
ways