svelte: Using components in creates duplicate elements on hydration
If we include a component inside <svelte:head>:
<svelte:head>
<A/>
</svelte:head>
with A.svelte:
<meta property="x" content="y"/>
this meta is duplicated, not fixed by #4082.
If this is discouraged we should throw a warning.
P.S.:
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>
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 12
- Comments: 20 (2 by maintainers)
Finally solved it! It wasn’t working for me even in 3.55 simply because of Cloudflare. This is the explanation https://github.com/sveltejs/svelte/issues/8112
All you have to do is turnoff autominify and brotli in Cloudflare Speed -> Optimization
Same on Sapper ^0.28.0 , i have a Meta component, to save me to write many times the metatags.
`<script> export let metadata = {}; </script>
<title>{metadata.title}</title> </svelte:head> `when i use it for each page i got the metatag even 3 timessvelte:head <Meta {metadata}/>This is hell 😦
I get two two title tags doing as per your example with sapper
On Thu, 1 Oct 2020, 13:29 Fábio Domingues, notifications@github.com wrote:
It indeed makes working with meta tags quite hard. They are essential for production news sites. Would love to see a fix. Happy holidays guys 🎄 Appreciate the work.
If it helps, I’m currently working around this issue with the following.
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.
This should be fixed now in 3.51.0.
Im seeing this too when i do:
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.