Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More flexible favicons #2591

Closed
MEO265 opened this issue May 28, 2024 · 6 comments
Closed

More flexible favicons #2591

MEO265 opened this issue May 28, 2024 · 6 comments
Labels
feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues

Comments

@MEO265
Copy link

MEO265 commented May 28, 2024

I have two points that could work together. I'm willing to create a PR, but I would like to know in advance what you think is the best option or whether the feature is not wanted at all.

First of all, I would really like to see support for svg favicons. All you would have to do is insert a line in the header above the other icons if the logo is an svg.

<link rel="icon" type="image/svg+xml" href="favicon.svg">

This would allow (monochrome) logos to also have a variant for dark mode users.

Additionally or alternatively, you could use the yamel to allow the code embedded in the header for the favicon to be overwritten.

@hadley
Copy link
Member

hadley commented May 28, 2024

Looks like only supported by ~77% of browsers (https://caniuse.com/link-icon-svg), so wouldn't want to make this the default, but maybe if you have an svg logo we could add it as an extra link?

https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7 suggests that dark mode support for svg requires custom css in the svg, which I suspect few folks will know how to do.

@hadley hadley added feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues labels May 28, 2024
@hadley
Copy link
Member

hadley commented May 28, 2024

So I don't think it makes sense to do this by default, but it would certainly be nice to give folks the ability to opt-in to an svg favicon. I think the main question on my mind is whether this needs to be an option, or if we could just have a convention for where such a file would be located. For example, maybe if pkgdown/favicon.svg existed, we could just add it to the <head> automatically? What do you think?

@MEO265
Copy link
Author

MEO265 commented May 30, 2024

For example, maybe if pkgdown/favicon.svg existed, we could just add it to the <head> automatically? What do you think?

I think it's a good idea to conditionally include the line depending on whether an SVG favicon (pkgdown/favicon.svg) exists. I will take care of the implementation and submit a PR.

@MEO265
Copy link
Author

MEO265 commented May 30, 2024

https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7 suggests that dark mode support for svg requires custom css in the svg, which I suspect few folks will know how to do.

Yes, that's true. However, https://realfavicongenerator.net/ offers not only its API but also a simple tool to create SVG favicons optimized for both dark and light mode.

Looks like only supported by ~77% of browsers (https://caniuse.com/link-icon-svg), so wouldn't want to make this the default, but maybe if you have an svg logo we could add it as an extra link?

When Apple (Safari) supports it, I will get back to you regarding the default behavior. Being able to work independently of the resolution is definitely an advantage, even without special features (e.g. dark mode support).

@hadley
Copy link
Member

hadley commented May 30, 2024

@MEO265 thanks for working on this!

@jayhesselberth
Copy link
Collaborator

I think this was addressed in #2804 but please reopen if you still have an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues
Projects
None yet
Development

No branches or pull requests

3 participants