structured-data-testing-tool icon indicating copy to clipboard operation
structured-data-testing-tool copied to clipboard

Support referencing schemas using @id

Open iaincollins opened this issue 5 years ago • 0 comments

Summary of proposed feature Allow @id to be used to reference one schema from another schema on the same page.

Purpose of proposed feature This format exists to publishers to avoid repeating the same information.

It is valid syntax used by some publishers (although it is not especially common).

For a more detailed explanation, see: https://webmasters.stackexchange.com/questions/98569/what-is-the-use-of-id-in-json-ld-syntax

Detail of the proposed feature

e.g. markup for a news article might look like:

{
  "@context": "http://schema.org",
  "@type": "NewsArticle",
  "publisher": {
    "@id": "https://www.nytimes.com/#publisher"
 }

And it might reference an organisation object on a page which looks like like this:

{
  "@context": "http://schema.org",
  "@type": "NewsMediaOrganization",
  "@id": "https://www.nytimes.com/#publisher",
  "name": "The New York Times",
  "logo": {
    "@context": "http://schema.org",
    "@type": "ImageObject",
    "url": "https://static01.nyt.com/images/misc/NYT_logo_rss_250x40.png",
    "height": 40,
    "width": 250
  },
}

For a real world, example, see: https://www.nytimes.com/2020/04/14/us/coronavirus-updates-usa.html

Potential problems

This could be done by either making the test logic more sophisticated or (perhaps more easily?) by 'unflattening' the data structures after parsing the page, which would mean the test logic doesn't need to change, and that could be better as it would be much simpler logic and avoid special case handling for this feature in an already complicated section of code.

Describe any alternatives you've considered

None

Additional context

None

iaincollins avatar Apr 14 '20 12:04 iaincollins