-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Duplicate <meta name="viewport"> if the custom one is defined in _document.js #6919
Comments
same issue on |
Anybody see this question? |
Our team ran into this problem as well and ended up moving our |
So the approach at the moment is to use _app instead of _document? |
@cesarvarela yes that is our approach at the moment and does seem to be working..but if anyone has any other suggestions or best practices, we'd love to hear them! |
@timneutkens should I make PR to rise a warning in production mode like for the title |
In my case, whenever i use "key" property on <meta name="viewport" ... />, unwanted duplicated meta tag appears like below. even in
|
@cheeki I made a PR to fix that but logically there is no need to use the |
key is needed if you have a child component rewriting the father's component "head". _app: ChildPage: |
I would like to confirm the Expected behavior so that I can solve this one as soon as possible
|
I think it's correct. |
@vzaidman what if they don't have a key value? I am considering it to be the same as the above |
I think that it's the right behavior check @vzaidman #6919 (comment) so if you want to overwrite the default meta you shouldn't use the key |
The expected behavior:
good to have:
|
I think I'm seeing the same issue with <meta charSet='utf-8' /> |
Hi! After careful review we've decided this is the intended behavior. Head elements that are expected to be deduped should be added using The correct solution in this scenario is to move to using |
It might help to mention this in the documentation https://nextjs.org/docs#custom-document |
Feel free to send a PR, @Soundvessel! |
A downside of this approach is whenever you need some npm package to build global |
For some reason duplicate was created if meta viewport was added in _document. See issue: vercel/next.js#6919
it was weird. see vercel/next.js#6919
vercel/next.js#6919 (comment) Adding key attribute to meta descriptions inside of <Head/> will stop duplicates. This fixes the issue of linking /set/[someid] not showing the correct preview title or image like intended.
I have the same issue. Quite crazy it's still not really solved. |
Same problem... and can't fix it. |
Hi, for now, I used _app.js and that solved the issue. Obviously, it's not exactly how it should be... |
For example:
|
I was getting a duplicate |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
I recently upgraded to the latest canary and noticed horizontal scrolling on some mobile devices. As it turned out, this was caused by #6754 (cc @developit).
Although the default new value of
viewport
is inserted only when there is no custom one, this logic did not work for me, because my customviewport
tag was in_document.js
and not inside<Head />
.Moving the tag into
<Head />
solved the issue, but it took a while to investigate.Expected behavior
It'd be great if Next.js searched for
<meta name="viewport" content="..." />
inside custom_document.js
and either did not insert the default one or asked developers to move their tag into<Head />
. WDYT folks?System information
The text was updated successfully, but these errors were encountered: