-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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>
duplicate tags when using +layout.svelte
#10089
Comments
Related: #1540 You can take a look here in the docs, which is the easiest solution atm iirc |
We can't solve this within Svelte itself, because each component renders itself "in isolation" and doesn't know about the head of others. So we'd need to check in SvelteKit that no tags are complete duplicates, i.e. same attributes - though are there tags in |
This comment was marked as duplicate.
This comment was marked as duplicate.
Shouldn't components be aware of what they have included in
I would expect page |
this issue is also impacting me, some pages seem to have dual |
You can use the So you can return the keywords in your page's <svelte:head>
{#if $page.data.keywords}
<meta ...>
{:else}
<meta ....>
{/if}
</svelte:head> As a workaround |
Describe the bug
This is similar to #6858, sveltejs/svelte#4533, sveltejs/svelte#6463, sveltejs/svelte#7444 but is SvelteKit specific.
When using
<svelte:head>
in+layout.svelte
, some tags are duplicated when then using<svelte:head>
on other pages. It looks like<title>
is de-duped successfully, but other meta tags slip through, giving duplicates.This is a problem for me when working with Opengraph tags - my hope was that the last tag attributed would just be picked up when sharing a link, but that doesn't seem to happen, and it's always picking up the first meta tag it finds instead. Since SvelteKit already elegantly handles duplicate
<title>
tags it feels like this is a bug, and that it should also account for duplicate<meta>
tags too.Potential work around here of course is just to define
<svelte:head>
in each individual page file, but this isn't ideal DX.Reproduction
https://www.sveltelab.dev/eq6abubatgq8jn1
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: