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

How to return several json-ld scripts? #247

Closed
arkhamvm opened this issue Jan 22, 2020 · 6 comments
Closed

How to return several json-ld scripts? #247

arkhamvm opened this issue Jan 22, 2020 · 6 comments
Labels
question Further information is requested

Comments

@arkhamvm
Copy link

Hi. I need to return two json-ld scripts - Article and BreadcrumbList which can't be joined one to each other, so i need two sepeated script tags in one component.
How i can do it?

@madsh93
Copy link

madsh93 commented Jan 29, 2020

I need to know this as well. Hopefully somebody can help us out 👍

@ymmooot
Copy link
Owner

ymmooot commented Jan 29, 2020

You can use @graph to dump multi structured data in one script tag.
Check this out 👉 named-graphs.

You can confirm that the following JSON-LD is valid with Structured Data Testing Tool - Google.

{
  "@context": "http://schema.org",
  "@graph":
  [
    {
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "item": {
            "@id": "https://example.com/articles/1",
            "name": "foo"
          }
        }
      ]
    },
    {
      "@type": "NewsArticle",
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://google.com/article"
      },
      "headline": "Article headline",
      "image": [
        "https://example.com/photos/1x1/photo.jpg",
        "https://example.com/photos/4x3/photo.jpg",
        "https://example.com/photos/16x9/photo.jpg"
      ],
      "datePublished": "2015-02-05T08:00:00+08:00",
      "dateModified": "2015-02-05T09:20:00+08:00",
      "author": {
        "@type": "Person",
        "name": "John Doe"
      },
      "publisher": {
        "@type": "Organization",
        "name": "Google",
        "logo": {
          "@type": "ImageObject",
          "url": "https://google.com/logo.jpg"
        }
      },
      "description": "A most wonderful article"
    }
  ]
}

@ymmooot ymmooot added the question Further information is requested label Jan 29, 2020
@arkhamvm
Copy link
Author

arkhamvm commented Jan 30, 2020

Thanks! I was missed the @graph notation.

@madsh93
Copy link

madsh93 commented Jan 30, 2020

Works like a charm. Thank you ymmooot 💃

@adarshmadrecha
Copy link

adarshmadrecha commented Oct 15, 2020

@ymmooot add this issue link or this solution in the readme.md file of the repo.
I am sure many users will be having this question.

@ymmooot
Copy link
Owner

ymmooot commented Oct 15, 2020

@adarshmadrecha I added the description to the README.md 01e5fab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants