0

I created this script and it validated fine in the Structured Data Testing Tool: http://data.co-op.place/pls/coop/p_seo_portal.therapists_object?in_portal_id=7047

it delivers:

{
"@context": "http://schema.org",
"@type": "ItemList",
"itemListElement": [
{
"@type": "ListItem",
"position": "1",
"url": "http://co-op.place/en_us-counsellors-taylorcreek/brittany-berg/"
}
,
{
"@type": "ListItem",
"position": "2",
"url": "http://co-op.place/en_us-counsellors-taylorcreek/craig-hollis/"
}
]
}

I then added it to the following wordpress page: http://co-op.place/en_us-counsellors-taylorcreek/ like so:

<script type="application/ld+json" src="http://data.co-op.place/pls/coop/p_seo_portal.therapists_object?in_portal_id= 7047">

When I test http://co-op.place/en_us-counsellors-taylorcreek/ in the Structured Data Testing Tool, I get JSON-LD Syntax error: value, object or array expected.

If I add the script directly to the page, I it validates correctly. However adding it directly won't work since the script can change over time. As new counsellors are added over time, the script will also deliver those new counsellors.

I'm at a loss as to why the using the script tag fails. Any ideas?

Ray DeBruyn
  • 41
  • 1
  • 7
  • Possible duplicate of [Where do I put Google's JSON-LD structured data?](https://stackoverflow.com/questions/39000408/where-do-i-put-googles-json-ld-structured-data) – unor Jan 11 '18 at 18:48
  • Yes - sorry. I didn't find this when searching. – Ray DeBruyn Jan 12 '18 at 16:44
  • unor - you mention in the other post that the json ld can be in the head or the body. My pages are quite a different animal using wordpress static pages to deliver dynamic content. When google fetches the page, it gets the dynamic content, but the structured data testing tool does not. I'm going to try this anyway, but do you know if google will capture json ld in the body delivered dynamically? – Ray DeBruyn Jan 12 '18 at 16:49
  • [Does Schema.org markup work if markup is dynamically built with JavaScript?](https://stackoverflow.com/q/29064209/1591669) – unor Jan 12 '18 at 19:43
  • nice - thank you! You've been quite helpful :) – Ray DeBruyn Jan 14 '18 at 07:37

1 Answers1

0

The SDTT, and other tools, expects the JSON-LD to be inline, rather than referenced via the src attribute. Consequently, it seems to be empty, and neither an object nor an array.

Gregg Kellogg
  • 1,831
  • 12
  • 8
  • Thanks Gregg :) I thought that may be the case, so I scoured the documentation and didn't find anything to suggest that. Is there a technical reference other than https://developers.google.com/search/docs/guides/? Maybe it's in there and I missed it lol – Ray DeBruyn Jan 12 '18 at 16:36
  • This comes from HTML, where the `src` attribute is reserved for _classic_ and _module_ types, JSON-LD is in a _data block_ type. The operative paragraph is: > When used to include data blocks, the data must be embedded inline, the format of the data must be given using the type attribute, and the contents of the script element must conform to the requirements defined for the format used. The src, charset, async, defer, crossorigin, and nonce attributes must not be specified. – Gregg Kellogg Sep 23 '18 at 01:11