-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Using components in <svelte:head> creates duplicate elements on hydration #4533
Comments
Same is occurring for me, this quite an issue for using Sapper for SEO-focused sites. |
I feel this issue has been raised, fixed and re-appear a few times ? These days, whenever my SERPS or Rankings drop I have to go look at Sapper/Svelte first. |
Note that this is only a problem in the reported example. There is no problem when done this way: <!-- Main.svelte -->
<A/> <!-- A.svelte -->
<svelte:head>
<meta property="x" content="y"/>
</svelte:head> |
I get two two title tags doing as per your example with sapper
…On Thu, 1 Oct 2020, 13:29 Fábio Domingues, ***@***.***> wrote:
Note that this is only a problem in the reported example. There is no
problem when done this way:
<!-- Main.svelte -->
<A/>
<!-- A.svelte -->
<svelte:head>
<meta property="x" content="y"/>
</svelte:head>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4533 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKF7JAG73AWZGMEDYZC7QTSIRRZ3ANCNFSM4LE6ZRKQ>
.
|
Seems to be the same issue as #1607, since it also happens even if it's not in a component. But it doesn't happen for all elements, I'm having trouble figure out what the difference is. |
If it helps, I'm currently working around this issue with the following. import { afterUpdate } from "svelte"
afterUpdate(() => {
Array.from(document.head.querySelectorAll("meta[data-svelte]"))
.forEach(e => e.remove())
}) It's not a perfect solution, but works for me as all the pre-hydrated meta tags have data attributes, probably from an earlier solution to this issue. |
Im seeing this too when i do: <svelte:head>
{@html page.yoast_head}
</svelte:head> |
It indeed makes working with meta tags quite hard. They are essential for production news sites. Would love to see a fix. |
I have the same issue on my sapper page as well. If I use a Svelte component to render the |
|
Same on Sapper ^0.28.0 , i have a Meta component, to save me to write many times the metatags. `<script>
This is hell :( |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This also affects |
This should be fixed now in 3.51.0. |
…as per conduitry on 'sveltejs/svelte#4533') ... the meta tag duplication SSR issue is not fixed. With this update I have commented out the custom hook function 'metaTagFixWhenSSR' as well
I was able to reproduce it in 3.55 though. |
Finally solved it! It wasn't working for me even in 3.55 simply because of Cloudflare. This is the explanation #8112 All you have to do is turnoff autominify and brotli in Cloudflare Speed -> Optimization |
@0x366 I tried the same as you did, but the issue still persists on my website :( There are some options that are still enabled: Do I also have to disable the above 👀? Or is there any other way to sort this out. Any help would be appreciated. |
I have both disabled, not sure if it's the case tho. I almost have all features disabled. Maybe it's worth a try to disable everything and see if it helps. And then turn on features one by one. |
@0x366 Thanks for the reply. I checked disabling each configurations 1 by 1 still that didn't worked out. |
Thanks a lot! This bothered me all day. |
If we include a component inside
<svelte:head>
:with
A.svelte
:this meta is duplicated, not fixed by #4082.
If this is discouraged we should throw a warning.
P.S.:
The text was updated successfully, but these errors were encountered: