-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
<svelte:head> creates duplicate elements on hydration #1607
Comments
I just checked, and this issue is plaguing Sapper as well. I've noticed that other frameworks add a data attribute to specify which elements are tracked. Would it help to add a data-svelte-head attribute to head elements to properly hydrate them on initial page load? |
Hi, is there any fix for this yet? We are using version 2.16.0 and are having this issue as well. |
I've been doing Sapper lighthouse tests because I want perfect SEO. Lighthouse told me to add
I just added the meta line, all else was there before, on each page. After adding the meta line I'm seeing two issues:
|
PR for this issue sveltejs/sapper-template#158 |
I cannot reproduce the problem with the current REPL (3.16.4). |
What were you doing to test? The REPL doesn't perform any hydration. |
@Conduitry Sorry, I overlooked that point. |
Presumably the way to address this would be to have the SSR code mark or delimit its One fairly obvious way to do this would be to a unique hash-based string for each component that's added as an attribute to each element in the component's SSR'd contribution to the Another option is some sort of wrapping element, or separating elements before and after this component's |
<meta data-react-helmet="true" property="og:type" content="website"> |
Fixed (finally!) in 3.17.0. |
@Conduitry Unfortunately this is happening again. We're using Sapper 0.28.9 and Svelte 3.28.0 (it was happening with 0.28.8 and 3.27.0 as well; I upgraded to see if that would fix it, but no luck). I'm having trouble pinpointing exactly what the pattern is, since not every route's I'll try to create a repro repo and post it tomorrow. |
Confirmed me as well. |
Im seeing this too when i do: <svelte:head>
{@html page.yoast_head}
</svelte:head> |
@matt3224 no need to post the same comment on multiple issues. you can simply give a thumbs up on the issue if you'd like to indicate it's one you care about |
any new on this? got all my meta tags duplicated |
This issue should be re-opened 🙏 |
I have a SvelteKit app deployed to production at https://c3.ventures and am not seeing this there. Maybe it's just an issue with Sapper? |
Sveltekit also solved this for me |
SvelteKit uses vite-plugin-svelte which automatically sets the |
Still experiencing this with sapper v0.29.2 & svelte v3.42.1 |
i am also having this problem in most recent svelte version, unfortunately. only with |
Tested on SvelteKit Project: Svelte v3.44.0 + SvelteKit v1.0.0-next.260
|
@benmccann Do you mean that we should disable |
I am seeing duplication for the generated I generate the json as string: export const mkSchema = (thing: Schema) => {
return `<script type="application/ld+json">${JSON.stringify(thing, null, 2)}</script>`;
}; And I am using it in <svelte:head>
{@html mkSchema(orgSchema)}
{@html mkSchema(webpageSchema)}
{@html mkSchema(websiteSchema)}
</svelte:head> |
No. I meant that if you're using Svelte without SvelteKit you may want to make sure your project is configured appropriately |
I'm using svelte 3.48.0 and sveltekit [email protected] and this issue still occurred when the meta elements were not direct children of svelte:head: <svelte:head>
<Meta title={variables.siteName} {url} {description} {image} /> <!-- contains multiple meta elements; this causes duplication -->
</svelte:head> <svelte:head>
<meta itemprop="name" content={title} /> <!-- this works as expected -->
<meta itemprop="description" content={description} />
</svelte:head> |
I love svelte, I really do ! But gheesh, one of the advantages of
svelte(kit) is the better SEO etc. After almost two years. I unfortunately
have to move on and can not in good faith, choose or recommend any of
svelte(kit) for any SEO sensitive projects.
…On Sat, May 7, 2022 at 6:26 PM Avoonix ***@***.***> wrote:
I'm using svelte 3.48.0 and sveltekit ***@***.*** and
this issue still occurred when the meta elements were not direct children
of svelte:head:
<svelte:head>
<Meta title={variables.siteName} {url} {description} {image} /> <!-- contains multiple meta elements; this causes duplication -->
</svelte:head>
<svelte:head>
<meta itemprop="name" content={title} /> <!-- this works as expected -->
<meta itemprop="description" content={description} />
</svelte:head>
—
Reply to this email directly, view it on GitHub
<#1607 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKF7JEWG54KOX2FKA3D3ALVI2KSRANCNFSM4FLG6WUQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Regards
Jacques du Rand
https://www.FibreTiger.co.za
|
@avoonix can you file a new issue? I'm afraid your comment would get lost here given how large this thread is |
Could we please reopen this? This is still an issue in Oct 2022. |
Please open a new issue with a proper reproduction, it's maybe the same outcome but likely not the same root cause. |
related svelte-meta-tags#556 |
When hydrating SSR-generated Svelte components, the svelte:head component creates duplicate elements. This seems to be true for all elements other than title. Please see the following repo:
https://github.com/morleytatro/svelte-head-test
Steps to repro:
The text was updated successfully, but these errors were encountered: