schemamarkup.wikiThe schema.org and structured data reference

mainEntity and mainEntityOfPage

From schemamarkup.wiki, the sourced reference on schema.org and structured data

mainEntity "indicates the primary entity described in some page or other CreativeWork," and mainEntityOfPage, its inverse, "indicates a page (or other CreativeWork) for which this thing is the main entity being described."[1][2] Together they answer the question many pages leave implicit: of all the things marked up here, which one is the page about? Schema.org's data model gives the two properties their own background note, and Google uses mainEntity as a required property in its profile page documentation.[3][4]

Definitions

PropertyExpected valuesSchema.org definition (quoted)
mainEntityThing"Indicates the primary entity described in some page or other CreativeWork."[1]
mainEntityOfPageCreativeWork, URL"Indicates a page (or other CreativeWork) for which this thing is the main entity being described."[2]
aboutThing"The subject matter of an object."[5]
urlURL"URL of the item."[6]
sameAsURL"URL of a reference Web page that unambiguously indicates the item's identity."[7]

Schema.org declares mainEntity a sub-property of about, so a page's main entity is always one of the things it is about.[1]

Schema.org background note

The data model note explains the purpose: "Many (but not all) pages have a fairly clear primary topic, some entity or thing that the page describes. For example a restaurant's home page might be primarily about that Restaurant, or an event listing page might represent a single event." The two properties "allow you to explicitly express the relationship between the page and the primary entity."[3]

It then separates mainEntityOfPage from neighboring properties. url "should be reserved to refer to more official or authoritative web pages, such as the item's official website." sameAs "relates a thing to a page that indirectly identifies it" and "emphasises well known pages," whereas mainEntityOfPage "serves more to clarify which of several entities is the main one for that page" and "can be used for any page, including those not recognized as authoritative for that entity." The note's example: for a product, sameAs might point to the manufacturer's specification page, while mainEntityOfPage is used on each retailer's page about the same product.[3]

On about versus mainEntity, the note says about "can refer to multiple entities/topics, while mainEntity should be used for only the primary one," and that for a news article about a person, mainEntity should be the article while about is the person.[3]

What Google documents

ProfilePage. Google's profile page markup requires mainEntity, "the person or organization that this profile page is about," and says it "indicates that the primary focus of this page is information about this entity."[4] See Person and ProfilePage.

QAPage. Google requires the Question to be "nested under the mainEntity property of the QAPage item," with exactly one Question per page.[8]

Preferred images. Google's image guidance lists two schema.org routes to a preferred page image: the primaryImageOfPage property, "or specify an image URL or ImageObject property and attach it to the main entity (using the schema.org mainEntity or mainEntityOfPage properties)." Google says image selection "is completely automated," so this influences rather than sets the choice.[9]

Main focus of the page. Google's general guidelines ask publishers to include "the main type of structured data that reflects the main focus of the page."[10] mainEntity is the schema.org way to say which node that is.

Common patterns

  • Home page of a business. WebPage with mainEntity pointing to the Organization or LocalBusiness node by @id.[3]
  • Service page. WebPage with mainEntity pointing to the Service node, and the Service's provider pointing to the business. See Service.
  • Article page. WebPage with mainEntity set to the Article; the article's about then names its subject.[3]
  • Profile page. ProfilePage with mainEntity set to the Person or Organization, as Google requires.[4]
  • Reverse form. Inside an Article node, mainEntityOfPage with the page URL. Google's own BlogPosting example in its image guidance uses this form.[9]

Common mistakes

  • Several main entities. The background note says mainEntity "should be used for only the primary one."[3]
  • Main entity not visible. Marking a page's main entity as a business the page does not describe conflicts with Google's relevance guideline.[10]
  • Confusing mainEntityOfPage with url. url is for the item's official or authoritative page; mainEntityOfPage can be any page whose main subject is the item.[3]
  • ProfilePage without mainEntity. Google lists it as required.[4]

Example

A fictional service page. The WebPage names the Service as its main entity; the Service points back with mainEntityOfPage, which repeats the same relation from the other side.

{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "WebPage",
      "@id": "https://www.example.com/water-heaters#webpage",
      "url": "https://www.example.com/water-heaters",
      "name": "Water heater repair",
      "mainEntity": { "@id": "https://www.example.com/water-heaters#service" },
      "primaryImageOfPage": { "@type": "ImageObject", "url": "https://www.example.com/img/water-heater.jpg" }
    },
    {
      "@type": "Service",
      "@id": "https://www.example.com/water-heaters#service",
      "name": "Water heater repair",
      "mainEntityOfPage": { "@id": "https://www.example.com/water-heaters#webpage" },
      "provider": { "@id": "https://www.example.com/#organization" }
    }
  ]
}

Common questions

Do I need both mainEntity and mainEntityOfPage?

No. They are inverses, so one direction states the relation.[1][2]

Is mainEntity the same as about?

mainEntity is a sub-property of about reserved for the primary entity.[1][3]

Does Google use mainEntity?

Yes, it is required in ProfilePage and QAPage markup and is one route to a preferred image.[4][8][9]

References

  1. ^ "mainEntity (property)". Schema.org.
  2. ^ "mainEntityOfPage (property)". Schema.org.
  3. ^ "Data model: background notes on mainEntity(OfPage) and identifier". Schema.org.
  4. ^ "Profile page (ProfilePage) structured data". Google Search Central.
  5. ^ "about (property)". Schema.org.
  6. ^ "url (property)". Schema.org.
  7. ^ "sameAs (property)". Schema.org.
  8. ^ "Q&A (QAPage) structured data". Google Search Central.
  9. ^ "Google image SEO best practices". Google Search Central.
  10. ^ "General structured data guidelines". Google Search Central.