Skip to content

Two JSON-LD tags #8802

@shuaixr

Description

@shuaixr

Describe the bug

Sveltekit generates two JSON-LD tags when configured with a domain in a production environment, here's a comparison between the domain and non-domain versions: http://45.56.85.226:3000/ and https://jsonld.shuaixr.xyz/

8ron3.png

When JavaScript is turned off in the browser, one of the JSON-LD tags disappears, so I didn't pay too much attention to it initially. However, recently I found that there were also two in Googlebot's crawled pages.

Also, I wrote a Svelte component like this for easy use of JSON-LD:

<script lang="ts">
	export let json_ld: unknown;
</script>

<svelte:head
	>{@html `
    <script type="application/ld+json">
            ${JSON.stringify(json_ld)}
    </script>`}
</svelte:head>

I am a beginner, this error may also be caused by my non-standard svelte component. If so, please inform me of the correct way.
I created a repository to reproduce the bug where there is all the code:https://github.com/shuaixr/jsonld_svelte
I created a website deployment of this repository:
https://jsonld.shuaixr.xyz

Reproduction

1.clone https://github.com/shuaixr/jsonld_svelte
2.npm run build
3.export PROTOCOL_HEADER=x-forwarded-proto && export HOST_HEADER=x-forwarded-host
3.node build/index.js

Logs

Listening on 0.0.0.0:3000

System Info

System:
    OS: Linux 5.10 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (1) x64 AMD EPYC 7542 32-Core Processor
    Memory: 374.07 MB / 976.58 MB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 18.12.1 - /usr/bin/node
    npm: 8.19.2 - /usr/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.2 => 1.0.2
    @sveltejs/adapter-node: ^1.1.4 => 1.1.4
    @sveltejs/kit: ^1.0.0 => 1.3.1
    svelte: ^3.54.0 => 3.55.1
    vite: ^4.0.0 => 4.0.4

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions