Categories
Uncategorized

Adding Icons to an Angular Web Site

Changing out the icons for an Angular website is just a few steps. This guide assumes you have an icon already in place, preferably in PNG format.

First, use a tool like Real Favicon Generator to create the source files, which will include a favicon.ico file alongside a series of apple-touch-icon* files. Add these files to the /src directory.

After that, make the following change to your index.html file:

<head>
    ...
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
    <link rel="manifest" href="/site.webmanifest">
    <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="theme-color" content="#ffffff">
</head>

And finally make the change to angular.json to ensure the files are delivered correctly on build:

"assets": [
            ...
            "src/android-chrome-192x192.png",
            "src/android-chrome-512x512.png",
            "src/apple-touch-icon.png",
            "src/browserconfig.xml",
            "src/favicon-16x16.png",
            "src/favicon-32x32.png",
            "src/mstile-150x150.png",
            "src/safari-pinned-tab.svg",
            "src/site.webmanifest"
          ],

To test that everything worked successfully, make sure to run a build:

ng build

After this finishes, check the /dist folder to see the icon files added in the step above.

Leave a Reply

Your email address will not be published. Required fields are marked *