Duplicate `<link rel="canonical">` in SolidStart
In my SolidStart project, I have the following code:
However, in the rendered output, there are two
I tried removing the
So, what is causing the duplication of the
However, in the rendered output, there are two
<link rel="canonical">
tags:I tried removing the
<Link>
tag from the code, and after rendering, there was no canonical link at all. This confirms that the <Link>
tag I added is the sole reason for the canonical link appearing.So, what is causing the duplication of the
<link rel="canonical">
tag in the rendered output, and how can I fix it? Or it dose not matter
thanks a lot15 Replies
Do you use the meta tags inside a
<MetaProvider>
? I am not sure, but maybe it would solve your issue.
MetaProvider example:
i believe OP is using solid meta. i think a reproduction is likely necessary for further debugging.
Not 100% sure about that. That's only my suggestion.
š
yeah, I'm only guessing but solid start basic template includes it by default +
data-sm
(what solid meta use to mark nodes it handles) made it clear, and solid meta already handles de-duplication so we definitely need a reproyeah that's kinda strange behavior
It haven't ever happened for me before tbh
yes, I am using solid-meta. Only Link has data-sm property in the page after rendered. If I removed <Link rel="canonical" href="https://www.example.com/" />, everything goes well.
- Created a fresh SolidStart project: TS/basic
- Replaced the
src/app.tsx
with this:
ā¦ which results in exactly this (from "view source"):
So unfortunately you haven't provided enough information for a reproduction.Just to add, de-duplication is only done for
title
and meta
at the moment so there's actually room for improvement for other tags too if warranted
but the initial problem seems to be duplicates caused by one element, where both ssr-ed and csr-ed tags existing at the same timethanks for helping showing how to use meta in solidstart app
but what about this?
like we have duplicate head?
Meta places its elements inside the existing head but it doesn't handle elements that already exist within it. It only modifies, removes elements that it placed there to begin with.
So like I keep the head in entry client or move it entirely to app.tsx?
Should i move all meta tags to app.tsx
And remove the head from that file I showed above
The
head
stays in src/entry-server.tsx
. You just use <Title/>
, <Meta />
, etc. in your components when they become relevant. The fallbacks (if any) would be specified right under the MetaProvider typically in the src/app.tsx
.Yeah I get it before you had solid meta built in it was better imo
Like now we have <head> and <Head>
In two different places
I'm not aware of any
<Head />
component.Ye sorry I confused with old solid start