Site Essentials for Statamic

Site Essentials for Statamic

Favicon Configuration

The favicon generation feature provides many different configuration options. You can disable the feature entirely, add/remove favicon sizes, and even change the favicon generation driver entirely.

#Disabling Favicon Features

The favicon generation features can be disabled by updating the enabled value within your site's site_essentials/favicons.php configuration file. When disabled, favicons will not be automatically added to your site's web manifest file (if using that feature), and the favicon generation commands will not do anything.

1<?php
2 
3return [
4 
5 /*
6 |--------------------------------------------------------------------------
7 | Favicon Generation Feature Toggle
8 |--------------------------------------------------------------------------
9 |
10 | The 'Enabled' configuration key activates the Site Essentials' favicon
11 | generation feature. When set to true, generated favicons will be
12 | added to generated manifest files, as well as other features.
13 |
14 */
15 
16 'enabled' => true,
17 
18 // ...
19 
20];

#Configuring Favicon Sizes

Additional favicon sizes can be managed within your site's site_essentials/favicons.php configuration file. All favicons must have the following properties:

  • rel: Added to the output link tag's rel attribute

  • format: The image format to convert to. This is used as part of the final file name, and to help determine the type attribute for the output link tag

  • size: The size of the final image, in pixels.

By default, the following sizes are pre-configured:

1<?php
2 
3return [
4 
5 // ...
6 
7 /*
8 |--------------------------------------------------------------------------
9 | Favicon Icons Configuration
10 |--------------------------------------------------------------------------
11 |
12 | The 'icons' array contains the set of favicon sizes to be generated.
13 |
14 | Icons must include:
15 | * 'rel': The relation attribute for the link element in HTML.
16 | * 'size': The dimensions of the favicon, like '16x16'.
17 | * 'format': The file format for the icon, e.g., 'png', 'jpg'.
18 |
19 */
20 
21 'icons' => [
22 [
23 'rel' => 'shortcut icon',
24 'size' => '16x16',
25 'format' => 'ico',
26 ],
27 [
28 'rel' => 'icon',
29 'size' => '16x16',
30 'format' => 'png',
31 ],
32 [
33 'rel' => 'icon',
34 'size' => '32x32',
35 'format' => 'png',
36 ],
37 [
38 'rel' => 'icon',
39 'size' => '192x192',
40 'format' => 'png',
41 ],
42 [
43 'rel' => 'icon',
44 'size' => '512x512',
45 'format' => 'png',
46 ],
47 [
48 'rel' => 'apple-touch-icon',
49 'size' => '180x180',
50 'format' => 'png',
51 ],
52 ],
53 
54 // ...
55 
56];

#Removing Existing Favicons

By default the favicon generator will attempt to cleanup any previously generated favicons. This feature can be disabled by changing the remove_existing configuration value within the site_essentials/favicons.php configuration file:

1<?php
2 
3return [
4 
5 // ...
6 
7 /*
8 |--------------------------------------------------------------------------
9 | Remove Existing Images
10 |--------------------------------------------------------------------------
11 |
12 | Determines whether existing favicons should be removed before
13 | generating new ones. This feature relies on the temporary
14 | path being writable by the web server, as it contains
15 | the file paths to the existing favicon images.
16 |
17 */
18 
19 'remove_existing' => true,
20 
21 // ...
22 
23];

When enabled, this feature relies on being able to write a JSON file containing the details about the favicons that were generated. Before new favicons are generated, this file is read and any previously generated icons are removed from the filesystem. You may update the folder this temporary file is stored in by changing the tmp_path configuration option within the same configuration file.

#Updating the Favicon Driver

If you've developed or installed a different favicon generation driver you will need to update the driver option within the site_essentials/favicons.php configuration file. Site Essentials for Statamic ships with an ImagickDriver by default.

1<?php
2 
3return [
4 
5 // ...
6 
7 /*
8 |--------------------------------------------------------------------------
9 | Image Resize Driver Configuration for Favicons
10 |--------------------------------------------------------------------------
11 |
12 | The 'Driver' setting identifies the specific image resizing driver
13 | the favicon generator will use. This driver handles the scaling of
14 | images to the appropriate dimensions for all favicons created.
15 |
16 */
17 
18 'driver' => \Stillat\StatamicSiteEssentials\Favicons\Drivers\ImagickDriver::class,
19 
20 // ...
21 
22];

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.