Where would you put favicon's? themes or user/pages/images?

I’m sure either is fine, but I’m trying to understand grav best practices.

On one hand, themes makes the most sense because you are almost always going to have a theme head.html.twig template which will always reference the same icon files. But then, if you wanted to make changes, you’d have to go through the trouble over creating an overriding theme (mytheme) in order to override the theme’s images directory.

One the other hand, user/pages is where a user should put his content. Since these icons will be different for each site…it seems they could also go into there.

Any thoughts?

I would put it in themes folder because if you would change the theme you would also maybe change the icon if its not matching the style for example, different color or different icon.

2 Likes

It’s a stylistic part of the website, so the theme is the logical place for it. Pages is for content, and the favicon should always be declared in HTML meta, governed by the theme.

2 Likes

There is not set rule, but I always like to keep it in the theme’s images/ folder.

2 Likes

You can check if an image is there in user/images/favicon.png and fallback to the default theme one using:

<link rel="icon" type="image/png" href="{{ url('user://images/favicon.png') ?: url('theme://images/favicon.png') }}" />

2 Likes

Hi, I have a similar issues while trying to simply use the antimatter theme. I want the site to use a favicon of mine. And i do not want to replace the one provided in themes/antimatter/images/ because I do not want to loose mine in case of a theme update.
Where shall I put mine for it to override the default one? But first is it feasible to override such an image?
I tried to put mine as

  • user/pages/images/favicon.png
  • users/config/themes/images/favicon.png

But none of these work… And I cannot find information about that in the tutorial…
Thanks for any hint!
Xavier

for antimatter, you have to put it inside user/themes/antimatter/images/ and you have to name it favicon.png (you will have to replace the existing one)

Clear, thanks Paul !

Implementing a new site, but this time with the Woo theme, I face the same difficulty again: how to override the default favicon but also the logo.png and footer_logo.png provided with the theme ?

I’m still confused for such customization. Shall I create a child theme with inheritance (cf. https://learn.getgrav.org/themes/customization) to do that?

Thanks for any clarification.
Xavier