19

Please take a look here: https://developers.google.com/structured-data/testing-tool?url=https%253A%252F%252Fglamourina.net%252Fen%252F

How can I correctly add mainEntityOfPage to this site?

In Google documentation example I see something like this:

<div itemscope itemtype="http://schema.org/NewsArticle">

  <meta itemscope itemprop="mainEntityOfPage"  itemType="https://schema.org/WebPage" itemid="https://google.com/article"/>

But this is a single author blog. And it features blogPosts.

<article itemscope itemtype="https://schema.org/BlogPosting" class="singlearticles">

Would it be good if I change it like this:

<article itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<meta itemscope itemprop="mainEntityOfPage"  itemType="https://schema.org/WebPage" itemid="https://linktoarticle"/>

Not sure if I understand well the mainEntityOfPage usage. I would appreciate if someone can suggest how can I do to this specific case/website. Not generically, because each site can have a different mainEntityOfPage, but I need to know and understand the right implementation for this site.

unor
  • 92,415
  • 26
  • 211
  • 360
Pikk
  • 2,343
  • 6
  • 25
  • 41

1 Answers1

52

About Google’s Microdata example

Google’s Microdata example is invalid. If the meta element has the itemprop attribute, the content attribute is required (details).

I described different ways how to specify mainEntityOfPage in Microdata, the most straigtforward one being a link element that creates a URL value (instead of another Microdata item):

<link itemprop="mainEntityOfPage" href="http://example.com/article-1" />

mainEntity

It’s easier to understand the use of mainEntityOfPage if we first look its inverse property, mainEntity.

For a WebPage that contains a BlogPosting, we could have:

<body itemscope itemtype="http://schema.org/WebPage">
  <article itemprop="mainEntity" itemscope itemtype="http://schema.org/BlogPosting">
  </article>
</body>

This means: There’s a WebPage and a BlogPosting, and the BlogPosting is the "primary entity" described in this WebPage. To denote this especially makes sense if there are more items involved, e.g., a Person describing the author, five more BlogPosting items for related posts, a WebSite item giving some metadata, etc. Thanks to mainEntity/mainEntityOfPage, consumers can learn what the primary/main item on that page is (i.e., what the page stands for).

mainEntityOfPage

The following example with mainEntityOfPage would result in equivalent structured data like the example with mainEntity from above:

<article itemscope itemtype="http://schema.org/BlogPosting">
  <div itemprop="mainEntityOfPage" itemscope itemtype="http://schema.org/WebPage">
  </div>
</article>

As you can see, the element for the BlogPosting item contains the element for the WebPage item. This is of course rather unusual markup.

But the mainEntityOfPage property does not only expect an (CreativeWork) item as value, it alternatively expects a URL. So instead of providing a WebPage item explicitly, you can provide the URL of the page instead:

<article itemscope itemtype="http://schema.org/BlogPosting">
  <link itemprop="mainEntityOfPage" href="http://example.com/article-1" />
</article>

(This is what Google expects, according to their documentation for the Articles Rich Snippet.)

Excursus: URL of page vs. post

Many sites don’t differentiate between the URL for the web page and the URL for the blog post. For these sites it might seem silly to state something like

http://example.com/article-1 (the blog post)
is the 'mainEntityOfPage' 
http://example.com/article-1 (the web page) 
http://example.com/article-1 (the web page) 
has 'mainEntity' 
http://example.com/article-1 (the blog post)

But it can be useful anyway (e.g., for choosing which item is the primary one, because the other items won’t have this statement; or for a blank node; etc.).

However, some sites do differentiate (especially for Linked Data), so they might state something like

http://example.com/article-1#this (the blog post)
is the 'mainEntityOfPage' 
http://example.com/article-1 (the web page) 
http://example.com/article-1 (the web page) 
has 'mainEntity' 
http://example.com/article-1#this (the blog post)

Here, http://example.com/article-1#this represents the blog posting, and http://example.com/article-1 represents the page with information about this posting (or the content of the posting itself). A clearer example would be a person and a page about this person; or a building and a page about this building. See my answer for an example why you might want to do this. (But, as explained above, you don’t have to differentiate; you can use the same URL for both.)

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • Thank you for all these details. What about my specific example? There I have `
    ` Should I remove `itemprop="blogPost"` from that and create something like this: `
    `
    – Pikk Dec 25 '15 at 23:54
  • 1
    @Pikk: No need to remove `blogPost` (and the parent `Blog` item). Especially thanks to `mainEntityOfPage`, having these other types is not problematic. You can give each `BlogPosting` the `link` element with `mainEntityOfPage` (pointing to the URL for the page that contains only this blog post). – unor Dec 26 '15 at 00:06
  • 2
    So you are saying that it's good to have two itemprop in the same section and have it like this: `
    ` ?
    – Pikk Dec 26 '15 at 00:09
  • 4
    @Pikk: Sure. It’s not different to having, for example, `

    Foo

    ` in the `BlogPosting` item. Each item (created via `itemscope`) has its own properties. Your `Blog` item has the property `blogPost`, your `BlogPosting` item has the property `mainEntityOfPage`.
    – unor Dec 26 '15 at 00:19
  • Thank you. Much appreciated – Pikk Dec 26 '15 at 00:28
  • See if http://www.seoskeptic.com/how-to-use-schema-org-v2-0s-mainentityofpage-property/ makes any sense. What solution did you use in the end? I'm in the same boat. – Ken Sharp Feb 25 '16 at 11:54
  • 2
    Respect for the properly validating ` – Andre Bulatov Mar 09 '16 at 01:48
  • @AndreBulatov: `meta content` is not intended for links. `link href` is intended for links. Adding an absolute url to the `content` attribute of a `meta` tag will error on the Yandex microdata testing tool whereas a `link` will not, because it's more semantic. – vhs Feb 09 '19 at 10:15