schemamarkup.wikiThe schema.org and structured data reference

hasPart and isPartOf

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

hasPart and isPartOf express that one creative work is part of another. Schema.org defines hasPart as indicating "an item or CreativeWork that is part of this item, or CreativeWork (in some sense)" and isPartOf as the reverse, and declares each the inverse of the other.[1][2] The most common use in an entity graph is WebPage isPartOf WebSite. Google's documented use is narrower: its paywalled content markup uses hasPart to point to the paywalled section of an article.[3]

Definitions

PropertyExpected valuesSchema.org definition (quoted)
hasPartCreativeWork"Indicates an item or CreativeWork that is part of this item, or CreativeWork (in some sense)."[1]
isPartOfCreativeWork, URL"Indicates an item or CreativeWork that this item, or CreativeWork (in some sense), is part of."[2]

The phrase "in some sense" in both definitions leaves the kind of whole-part relation open: a page in a site, an article in a periodical issue, an episode in a series, a chapter in a book or a section of a page.[1][2] Both domains are CreativeWork, so the properties are not meant for physical containment (for places, schema.org has containedInPlace) or for organizational structure (parentOrganization, subOrganization and department).[4][5][6]

Schema.org also defines narrower relations for particular kinds of works. These are better choices when they fit, because Google's general guidelines ask publishers to "use the most specific applicable type and property names defined by schema.org."[7]

PropertyExpected valuesSchema.org definition (quoted)
workExampleCreativeWork"Example/instance/realization/derivation of the concept of this creative work."[8]
exampleOfWorkCreativeWork"A creative work that this work is an example/instance/realization/derivation of."[9]
mainEntityOfPageCreativeWork, URL"Indicates a page (or other CreativeWork) for which this thing is the main entity being described."[10]
containedInPlacePlace"The basic containment relation between a place and one that contains it."[4]

workExample and exampleOfWork relate a work to its editions or realizations, not to its parts.[8]

What Google documents

Google's subscription and paywalled content documentation marks the article with isAccessibleForFree set to false and gives it a hasPart value of type WebPageElement, itself with isAccessibleForFree false and a cssSelector that matches the paywalled element, such as ".paywall".[3] Google says this markup "helps Google differentiate paywalled content from the practice of cloaking."[3] The selector has to match a class on the page; schema.org's cssSelector definition notes that "multiple matches within a page can constitute a single conceptual 'Web page element'."[11]

Google's feature documentation does not otherwise list hasPart or isPartOf as required or recommended for a rich result.[12] In an entity graph, WebPage isPartOf WebSite records which site a page belongs to; Google's site name documentation, which reads the WebSite on the home page, does not say whether it follows isPartOf from inner pages.[13]

Common patterns

  • Page in a site. WebPage isPartOf the WebSite node by @id.[2]
  • Post in a blog. BlogPosting isPartOf a Blog, or the Blog hasPart the posts.[14]
  • Guide with sections. A long Article hasPart smaller CreativeWork or WebPageElement nodes when sections are separately meaningful.[1][15]
  • Paywalled section. NewsArticle hasPart WebPageElement with isAccessibleForFree false and a cssSelector.[3]
  • Glossary. A DefinedTermSet uses hasDefinedTerm rather than hasPart for its terms. See DefinedTerm and DefinedTermSet.[16]

Parts of a web page

Schema.org also models parts of a single page. WebPageElement is defined as "A web page element, like a table or an image."[15] It has these subtypes, each with its own schema.org definition:

TypeSchema.org definition (quoted)
SiteNavigationElement"A navigation element of the page."[17]
Table"A table on a Web page."[18]
WPAdBlock"An advertising section of the page."[19]
WPFooter"The footer section of the page."[20]
WPHeader"The header section of the page."[21]
WPSideBar"A sidebar section of the page."[22]

The WebPage properties that point to these parts are mainContentOfPage, defined as "Indicates if this web page element is the main subject of the page."[23] and significantLink and relatedLink, which are covered on the WebPage and WebSite page. The one place Google's structured data documentation uses WebPageElement is its paywalled content guidance, where an article's hasPart holds a WebPageElement with isAccessibleForFree set to false and a cssSelector naming the paywalled section.[3]

Common mistakes

  • Using hasPart for organizations or places. Use subOrganization, department or containsPlace.[24][6][25]
  • Selectors that match nothing. A paywall cssSelector must match the element that holds the paywalled content.[3]
  • Contradictory pairs. If page A isPartOf B, B should not also be marked isPartOf A, because the properties are inverses.[2]
  • Parts not on the page. Google's guidelines apply: mark up what readers can see.[26]

Example

A fictional blog post that is part of a blog, which is part of a website.

{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "BlogPosting",
      "@id": "https://www.example.com/blog/tankless-guide#article",
      "headline": "A guide to tankless water heaters",
      "isPartOf": { "@id": "https://www.example.com/blog#blog" }
    },
    {
      "@type": "Blog",
      "@id": "https://www.example.com/blog#blog",
      "name": "Example Plumbing blog",
      "isPartOf": { "@id": "https://www.example.com/#website" }
    }
  ]
}

Common questions

Are hasPart and isPartOf inverses?

Yes. Schema.org declares each the inverse of the other.[1][2]

Does Google use hasPart?

Yes, in paywalled content markup, with a WebPageElement and cssSelector.[3]

Can isPartOf take a URL?

Yes. Its range is CreativeWork or URL.[2]

References

  1. ^ "hasPart (property)". Schema.org.
  2. ^ "isPartOf (property)". Schema.org.
  3. ^ "Subscription and paywalled content (CreativeWork) structured data". Google Search Central.
  4. ^ "containedInPlace (property)". Schema.org.
  5. ^ "parentOrganization (property)". Schema.org.
  6. ^ "department (property)". Schema.org.
  7. ^ "General structured data guidelines". Google Search Central.
  8. ^ "workExample (property)". Schema.org.
  9. ^ "exampleOfWork (property)". Schema.org.
  10. ^ "mainEntityOfPage (property)". Schema.org.
  11. ^ "cssSelector (property)". Schema.org.
  12. ^ "Structured data markup that Google Search supports (search gallery)". Google Search Central.
  13. ^ "Provide a site name to Google Search". Google Search Central.
  14. ^ "Blog (type)". Schema.org.
  15. ^ "WebPageElement (type)". Schema.org.
  16. ^ "hasDefinedTerm (property)". Schema.org.
  17. ^ "SiteNavigationElement (type)". Schema.org.
  18. ^ "Table (type)". Schema.org.
  19. ^ "WPAdBlock (type)". Schema.org.
  20. ^ "WPFooter (type)". Schema.org.
  21. ^ "WPHeader (type)". Schema.org.
  22. ^ "WPSideBar (type)". Schema.org.
  23. ^ "mainContentOfPage (property)". Schema.org.
  24. ^ "subOrganization (property)". Schema.org.
  25. ^ "containsPlace (property)". Schema.org.
  26. ^ "Introduction to structured data markup in Google Search". Google Search Central.