-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
Provide documentation on configuring .jsonld files to be loaded as script #9052
Comments
How is this specific to Docusaurus?
How would you do this on any other non-Docusaurus site? The general guideline is that anything in Docusaurus can't be a reference regarding SEO and structured data, there are other reference sites that explain good practices. I'm not an expert but as far as I know, you can insert structured data:
None of those methods are specific to Docusaurus. We provide generic apis that allow you to do that, but can't document all the use-cases for using those apis. Note that the 2/3 methods allow you to provide structured data that is different for each page of your site, while the 1st is more for site-wide structured data. |
cc @johnnyreilly maybe you have an opinion on how we could lightly document how to use microdata/jsonld/structured data? We probably don't want to copy/paste authority sites best practices but we could add some external links and mention various possibilities. |
I'm happy to push this over to the docusaurus.community site, but I thought a brief mention of |
Adding Any
I don't understand what you mean by "the content of the jsonld file itself does not show up in between the <script> tags" Docusaurus does no magic here, if you add a script tag, it will add the script page to the html page as is, that's all it does. Don't expect Docusaurus to fetch the content of it and insert it as a string in the static page. Having the script tag added this way to your page is definitively the expected behavior: <script src="seo_homepage.jsonld" type="application/ld+json" defer="" async=""></script>
I have no idea what you mean by "trying to read from src".
My intuition is that you try to put Eventually you should do Again, Docusaurus does absolutely 0 magic here, it just adds a script tag as is. There's no "processing" or whatever, it is just how html works. If all your pages contain a script with src |
@slorber Firstly, thanks for your patience! Still having bits of problems, but anyways I was frantically trying to find the easiest route to add this to only the homepage: <script src="seo_homepage.jsonld" type="application/ld+json" defer="" async="">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Homi",
"url": "https://homihq.com",
"logo": "https://homihq.com/img/logo-black.png"
}
</script> But I think I have my answer after spending a few hours all over the docs... which is unfortunate and where I think that structured-content section could improve. After those few hours spent by me, I think what is likely the missing piece of documentation under the https://docusaurus.io/docs/seo#structured-content would be a light mention something along the lines of:
What do you think of the above quote or similar going into that structured-content section in a PR by me? |
Structured data is not different from any other head metadata, which is already covered on that page: What makes you think that those 2 need a distinct treatment?:
It's exactly the same case. There's an infinite of possible metadata we could add on this doc page, so do we really need to be exhaustive and try to document them all? BTW, what is even the purpose of having Eventually, we could make the export default function page() {
return (
<Layout title="Page" description="A React page demo">
<Head>
<meta property="og:image" content="image.png" />
<meta name="twitter:card" content="summary_large_image" />
<link rel="preconnect" href="https://example.com" />
<script type="application/ld+json">
{JSON.stringify({
"@context": "https://schema.org/",
"@type": "Organization",
name: "Meta Open Source",
url: "https://opensource.fb.com/",
logo: "https://opensource.fb.com/img/logos/Meta-Open-Source.svg"
})}
</script>
</Head>
{/* ... */}
</Layout>
);
} About the prefetch thing, that seems unrelated to me. If you see a bug related to this, open a repro. It might simply be due to localhost hot code reloading after your live edits. |
You might be well right. So let's close this issue. |
Great Will still add a few other metadata in the example, this might help users to understand |
Please review this PR and let me know if it makes things clearer: #9071 |
Have you read the Contributing Guidelines on issues?
Description
We currently do OK by mentioning that scripts can be loaded.
https://docusaurus.io/docs/api/docusaurus-config#scripts
Great!
However, we should provide an example to also be linkable to our SEO section for https://docusaurus.io/docs/seo#structured-content.
For example, it's unclear what or where the best convention is (so we should provide a paragraph on guidelines under structured-content and also under the API reference for docusaurus-config#scripts) when a user has created their
.jsonld
file for Schema.org context to be loaded. Where to place the.jsonld
file in Docusaurus file hierarchy is a bit unclear as a best practice. Should it go under/src
? Or/static
? or/assets
? somewhere else?where in Docusaurus file heirarchy do I place my
seo_homepage.jsonld
file to be properly loaded in this example?Self-service
The text was updated successfully, but these errors were encountered: