Skip to content

mainEntityOfPage json-ld example needlessly differs from rdfa, microdata examples #2786

@danbri

Description

@danbri

in https://schema.org/mainEntityOfPage we have

{
    "@context": "https://schema.org",
      "@type": "Restaurant",
      "mainEntityOfPage": {
         "@type": "WebPage",
         "@id": "http://cathscafe.example.com/"
      },
      "name": "Cath's Cafe",
      "openingHours": "Mo,Tu,We,Th,Fr,Sa,Su 11:00-20:00",
      "telephone": "+155501003344",
      "hasMenu": "/menu"
}

This is verbose, and boring, and parses to a different structure than the RDFa and Microdata samples nearby.

It is rarely useful to go to the trouble of saying that a web page is a WebPage. We have done it here because having

 "mainEntityOfPage": { "@id": "http://cathscafe.example.com/" }

... on its own breaks the informal schema.org convention of supplying types where there is a syntactic context to include them easily.

However, schema.org's JSON-LD context file declares mainEntityOfPage to default to identifiers, so we could just write:

 "mainEntityOfPage": "http://cathscafe.example.com/" 

... and have this parse out to a URI. Let's do that.

The verbose / boring form is not wrong just a little bit pointless and slightly unusual. Having our examples across syntaxes encode exactly the same graph is generally a good thing and a sensible default. There may be cornercases (e.g. markup in literals, which microdata can't do; also breadcrumbs) where examples in different syntaxes can diverge, but let's try to minimize this practice.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions