-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
favicon file overwrites icons defined in metadata #55767
Comments
Hello, you don't need to pass the icons in the Metadata object. In the branch that you have as "works", you are trying to manually tell the icons, you just need to add these to the public directory, but I think it is better that you follow the option that is officially recommend in the documentation. |
Hey @hipdev! I originally ran into this issue because I was trying to create a link to an SVG What I was trying to do, and the underlying bug I'm reporting, is that I wanted to use both their recommended approach with the |
Ohh, now I get it, thanks for clarifying @KirillTregubov 😄, and you're totally right, for the time being there is no a way to mix them, I checked locally, so in order to have a mask-icon you will have to move any default supported icons inside the app folder to the public folder and use the Metadata object only. I found this about the topic. This is a good issue, would be better to allow a mix of both. |
It's not a perfect solution, but my workaround involved setting it on the client side through JavaScript. 'use client';
import { useEffect } from "react";
export default function Client() {
useEffect(() => {
let link = document.querySelector("link[rel='mask-icon']");
if (!link) {
link = document.createElement('link');
link.rel = 'mask-icon';
link.href = '/pwa/safari-pinned-tab.svg';
link.color = "#ed5f68";
document.head.appendChild(link);
}
}, []);
return null;
} |
I hope to point favicon.ico to the CDN address, because the serverless service I use will waste a calculation if I request ip/faviocn.ico. Is there any solution to solve this? |
- requires passing icons in metadata oject instead of via app router: vercel/next.js#55767 - sets custom icon for safari pinned tab vs. generic monogram icon
Still having the same problem. I'm on Next.js version 14.2.3 The following code export const metadata: Metadata = {
...
icons: {
shortcut: "/favicon.ico",
other: {
rel: "mask-icon",
url: "/icons/safari-pinned-tab.svg",
color: "#f45d22",
},
},
}; has no effect. Just because there are icons in the app folder, it ignores those in the metadata. |
Still a problem, the metadata is straight up ignored even if there are no icon files in the app folder. |
### What Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. ### Why `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
### What Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. ### Why `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
### What Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. ### Why `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
### What Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. ### Why `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
### What Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. ### Why `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
Link to the code that reproduces this issue
https://github.com/KirillTregubov/nextjs-icons-issue
To Reproduce
<link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16">
is the only icon in<head>
Current vs. Expected behavior
Following the steps from the previous section, I expect all icons defined in
app/layout.tsx
underexport const metadata
to appear in the<head>
element. But I observe that only<link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16">
(the favicon) is present.In other words, my goal is to use both your recommended approach of including a
favicon.ico
file in the correct place, and defining additional (read: different) icons using themetadata
export.This correct behaviour can be observed on the
works
branch, which shows that the issue is a direct result of thefavicon.ico
file handling inapp
. I realize that the reproduction template does not place the favicon inapp
, but both the default template and the docs instruct users to place it there.Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Metadata (metadata, generateMetadata, next/head)
Additional context
I find it inconsistent that the
reproduction-template
includes thefavicon.ico
in thepublic
folder instead of theapp
directory.Also please note that your
next info
command has a bug. I am actually on Windows 11 Home, but it says I am on Windows 10.The text was updated successfully, but these errors were encountered: