Skip to content
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

Duplicative JSON-LD Output #254

Closed
vhscom opened this issue Mar 11, 2022 · 4 comments
Closed

Duplicative JSON-LD Output #254

vhscom opened this issue Mar 11, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@vhscom
Copy link

vhscom commented Mar 11, 2022

Describe the bug
Writing JSON-LD to the page results in duplicative output.

Reproduction

  1. git clone https://github.com/vhscom/repro-duplicative-jsonld-meta.git to copy minimal test case
  2. pnpm i && pnpm dev -- --open to open the error page
  3. Observe the following in dev and production builds:
    <!-- HTML_TAG_START -->
    <script type="application/ld+json">{ ... }</script>
    <!-- HTML_TAG_END -->
    <script type="application/ld+json">{ ... }</script>

Additional context
Issue reproduced by initializing a fresh SvelteKit project and copy/pasting README example for JSON-LD. See the pnpm-lock.yaml for the exact resource versions used to reproduce, copied below for convenience:

  • '@sveltejs/kit': 1.0.0-next.295_svelte@3.46.4
  • svelte-meta-tags: 2.3.4_svelte@3.46.4+typescript@4.6.2

Aside
JSON-LD gets moved to page head whereas I'd expect it to output where the JsonLd tag is placed.

@vhscom vhscom added the bug Something isn't working label Mar 11, 2022
@oekazuma
Copy link
Owner

Hmmm... This seems to be a bug in Svelte hydration.
It seems that an issue has already been created, but it has not been resolved😅
sveltejs/svelte#6463

I added the following code to index.svelte and it solved the problem, but hydrate will not work...

<script context="module">
  export const hydrate = false;
</script>

@vhscom
Copy link
Author

vhscom commented Mar 11, 2022

Ah, I'd've found it but I only searched kit and not svelte. I saw in the Kit changelog there were some changes recently related to hydration so it seems this is a non-issue. Please close at your leisure. Thank you!

@nikolayh
Copy link

is there any solution?

@oekazuma
Copy link
Owner

This is a bug that occurs when rendering against <head>, so it can be worked around by rendering against <body>.
This feature was added in svelte-meta-tags v2.4.0.

docs: https://github.com/oekazuma/svelte-meta-tags#json-ld-properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants