amphtml: SDTT errors on template[type=amp-mustache]

Google Structured Data Testing (GSDTT) validates JSON-LD and is a proxy for Google Knowledge Graph. Our goal is to inject an AMP document with JSON-LD using amp-list and amp-mustache.

Here is sample JSON-LD:

{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "@id": "#website",
  "url": "https://afdsi.org/",
  "name": "Structured Data Provider",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://afdsi.org/?s={search_term_string}",
    "query-input": "required name=search_term_string"
  }
}

And as a string:

{"@context":"http://schema.org","@type":"WebSite","@id":"#website","url":"https://afdsi.org/","name":"Structured Data Provider","potentialAction":{"@type":"SearchAction","target":"https://afdsi.org/?s={search_term_string}","query-input":"required name=search_term_string"}}

JSON-LD string is valid on GSDTT

Our conventional technique uses jQuery. Here is a working example in a non-AMP page: https://afdsi.org/index.html Click link to Google’s Structured Data Testing Tool. See results on lower left.

Our first amp-list step is to transform JSON-LD into amp-list format (verified to be valid JSON)

{"items":[
{"link":"{\"@context\":\"http://schema.org\",\"@type\":\"WebSite\",\"@id\":\"#website\",\"url\":\"https://afdsi.org/\",\"name:Structured Data Provider\",\"potentialAction\":{\"@type\":\"SearchAction\",\"target\":\"https://afdsi.org/?s=?{search_term_string}\"}}"}
]}

Example is rendered here: https://afdsi.org/amp-list-03/ Page is valid AMP. When rendered on GSDTT: https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fafdsi.org%2Famp-list-03%2F we see the following:

"Uncategorized error"
<script type="application/ld+json">
  {{link}}
</script>

{{link}} is highlighted

For us, this is a severity-1 issue; we have no work-around and cannot achieve the result we customarily achieve using jQuery in a non-AMP page.

Are we doing something wrong? Is there a work-around that enables an AMP page, using amp-list, to inject JSON-LD and to be harvested – as is achieved with the jQuery example?

Aside: Microdata or RDFa is not an acceptable work-around 😉

We see these discussions: https://github.com/ampproject/amphtml/issues/6229#issuecomment-408954289 https://github.com/ampproject/amphtml/pull/16782

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 21 (3 by maintainers)

Most upvoted comments

😃 fair enough!

I’ll leave this to the usual prioritization mechanisms.

I’d also very much encourage you to ask the working group if you can add this feature to AMP yourself. As I’m sure you can imagine, engineering time is always finite. In fact, I’d encourage you to also come to the AMP Contributor Summit later this month. It’ll be part of the OpenJS Collaborator Summit.