6

for other areas of a web page it is simple to mark up; i.e. navigation element, header, footer, sidebar

Not so with mainContentOfPage; I've seen a number of different ways to implement this, most recently (and I found this one to be the most strange) on schema.org itself:

<div itemscope itemtype="http://schema.org/Table">
  <meta itemprop="mainContentOfPage" content="true"/>
  <h2 itemprop="about">list of presidents</h2>
  <table>
    <tr><th>President</th><th>Party</th><tr>
    <tr>
      <td>George Washington (1789-1797)</td>
      <td>no party</td>
    </tr>
    <tr>
      <td>John Adams (1797-1801)</td>
      <td>Federalist</td>
    </tr>
    ...
  </table>
</div>

I could use some examples; the main content of my page is in this case a search results page, but I would plan to use this on other pages too (homepage, product page, etc.)

Edit, I found some more examples:

Would this be valid? I found this on a blog:

<div id="main" itemscope itemtype="http://schema.org/WebPageElement" itemprop="mainContentOfPage">
    <p>The content</p>
</div>

I also found this even simpler example on another blog (might be too simple?):

<div id="content" itemprop="mainContentOfPage">
    <p>The content</p>
</div>
unor
  • 92,415
  • 26
  • 211
  • 360
Drewdavid
  • 3,071
  • 7
  • 29
  • 53

2 Answers2

5

The mainContentOfPage property can be used on WebPage and expects a WebPageElement as value.

But Table is not a child of WebPage and true is not an expected value. So this example is in fact strange, as it doesn’t follow the specification.

A parent WebPage should use Table as value for mainContentOfPage:

<body itemscope itemtype="http://schema.org/WebPage">
  <div itemprop="mainContentOfPage" itemscope itemtype="http://schema.org/Table">
  </div>
</body>

EDIT: Update

Your second example is the same like mine, it just uses the more general WebPageElement instead of Table. (Of course you’d still need a parent WebPage item, like in my example.)

Your third example is not in line with schema.org’s definition, as the value is Text and not the expected WebPageElement (or child) item.

unor
  • 92,415
  • 26
  • 211
  • 360
  • See also this [mail](http://lists.w3.org/Archives/Public/public-vocabs/2012May/0036.html) where it says: "`mainContentOfPage` (not officially a boolean) […]" – unor Apr 12 '14 at 15:21
  • Seems that mainContentOfPage should go around all of the content that is structurally the main area for unique content in the page, rather than being restricted to one HTML element...? Is there an alternative method of accomplishing this (i.e. designating a whole section as the main area)? – Drewdavid Apr 14 '14 at 18:38
  • @Drewdavid: Well, it needs to be a `WebPageElement` item (or one of its childs). On which HTML element you specify this `WebPageElement` doesn’t matter (with [some exceptions](http://stackoverflow.com/a/20808963/1591669)). You could also use [several](http://stackoverflow.com/a/21239191/1591669) `mainContentOfPage` properties, e.g., if relevant elements are scattered on the page. – unor Apr 14 '14 at 18:42
  • Thanks, updated my question to include some examples. So just including WebPageElement itself is ok then? – Drewdavid Apr 14 '14 at 18:46
  • @Drewdavid: I updated my answer. Yes, you can of course use `WebPageElement`, as I wrote in my answer. Schema.org’s expected types always apply to the mentioned type and all its children. – unor Apr 14 '14 at 19:02
  • @unor: Why the third example is not valid? According to [schema.org](https://schema.org/docs/gs.html) it is allowed to use text instead of specific type. Quote: **"...many properties have "expected types". This means that the value of the property can itself be an embedded item. But this is not a requirement - it's fine to include just regular text or a URL"** – gamliela Jun 02 '15 at 19:03
  • @gamliela: Yes, Schema.org [allows](http://stackoverflow.com/a/28571729/1591669) it. That’s why I didn’t use the term "invalid", but "not in line with schema.org’s definition": it’s recommended/preferred to provide the expected values from the property’s definition. Using text *might* be better than not providing the property in the first place, but it’s likely that many consumers won’t do something with your data in that case. – unor Jun 03 '15 at 08:53
  • It also worth to mention that google [validation tool](https://developers.google.com/structured-data/testing-tool/) has no problem with this case, although it doesn't guarantee anything. – gamliela Jun 04 '15 at 06:22
0

A valid option would be:

<body itemscope itemtype="http://schema.org/WebPage">
 <main itemprop="mainContentOfPage" itemscope itemtype="http://schema.org/WebPageElement">
  <div itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
   <h1 itemprop="name">whatever</h1>
  </div>
 </main>
</body>

Of course you may add related properties to top-level or nested elements, and change Thing into any other item type listed at Full Hierarchy. I also recommend to use mainEntity, documentation still doesn't clarify if it's really necessary, but according to 1st example here, using WebPage you may want to specify a mainEntity:

<body itemscope itemtype="http://schema.org/WebPage">
 <header><h1 itemscope itemprop="mainEntity" itemtype="http://schema.org/Thing">whatever</h1></header>
  <main itemprop="mainContentOfPage" itemscope itemtype="http://schema.org/WebPageElement">
   <div itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
    <h2 itemprop="name">whatever</h2>
    </div>
 </main>
</body>

Cannot tell if also this would be valid:

<body itemscope itemtype="http://schema.org/WebPage">
 <main itemprop="mainContentOfPage" itemscope itemtype="http://schema.org/WebPageElement">
  <div itemprop="mainEntity" itemscope="" itemtype="http://schema.org/Thing">
   <h1 itemprop="name">whatever</h1>
  </div>
 </main>
</body>    

Documentation doesn't say nothing about setting mainEntity to nested items.

In any case, consider that "[...] Every web page is implicitly assumed to be declared to be of type WebPage [...]" as stated in WebPage description, and use of HTML tags as <main>, <footer> or <header> already gives information about what type of elements are used in a page. So if actually you do not need to add relevant information to those elements or to your web page itself, with a proper use of HTML tags you could easily do without mainContentOfPage or even WebPage.

cosphi
  • 101
  • 5