pyld icon indicating copy to clipboard operation
pyld copied to clipboard

Examples of usage with Google's Structured Data JSON LD?

Open tony opened this issue 8 years ago • 5 comments

Despite this being the premier JSON-LD library for python, the examples are sparse and leave a lot to the imagination. Or maybe it's just me. In frustration I ended up resorting to dicts and json for now, but wanted to see if we could get some more examples and documentation up.

Here are examples of outputting jsonld Google's way:

https://developers.google.com/search/docs/guides/

Breadcrumbs: https://developers.google.com/search/docs/data-types/breadcrumbs

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "https://www.example.com/",
  "potentialAction": [{
    "@type": "SearchAction",
    "target": "https://query.example.com/search?q={search_term_string}",
    "query-input": "required name=search_term_string"
  },{
    "@type": "SearchAction",
    "target": "android-app://com.example/https/query.example.com/search/?q={search_term_string}",
    "query-input": "required name=search_term_string"
  }]
}
</script>

https://developers.google.com/search/docs/data-types/logo

{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "http://www.example.com",
  "logo": "http://www.example.com/images/logo.png"
}

https://developers.google.com/search/docs/data-types/articles

{
  "@context": "http://schema.org",
  "@type": "NewsArticle",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://google.com/article"
  },
  "headline": "Article headline",
  "image": {
    "@type": "ImageObject",
    "url": "https://google.com/thumbnail1.jpg",
    "height": 800,
    "width": 800
  },
  "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",
      "width": 600,
      "height": 60
    }
  },
  "description": "A most wonderful article"
}

tony avatar Aug 07 '17 23:08 tony

+1

gustavorps avatar Aug 08 '17 04:08 gustavorps

It is not just you.. also falling back to dicts and json for now.

tkremmel avatar Feb 01 '18 20:02 tkremmel

What kind of examples and docs were you all looking for? It could be argued that generic JSON-LD authoring and usage info should be on some other site. Improved docs for pyld in particular would be very welcome. Does anyone have suggestions (or patches!) on what do add?

davidlehn avatar Feb 01 '18 21:02 davidlehn

I tried to build structured data for a BlogPosting. So one suggestion would be to provide more examples which also include nestings.

{
	"author": "Tom",
	"publisher": {
		"logo": {
			"width": "234",
			"name": "mylogo",
			"url": "https://www.example.com/logo.png",
			"height": "76",
			"@type": "ImageObject"
		},
		"name": "My Example Orga",
		"@type": "http://schema.org/Organization"
	},
	"datePublished": "2018-01-15",
	"headline": "My Example Headline",
	"dateModified": "2018-02-01",
	"@type": "BlogPosting",
	"image": "https://www.example.com/media/file/example.jpg",
	"@context": "http://schema.org"
}

tkremmel avatar Feb 01 '18 22:02 tkremmel

@davidlehn An example for, given a json-ld file, how would one open it? Use it? Get dependencies? Complete mystery.

bcipolli avatar May 22 '20 23:05 bcipolli