How to implement "mainEntityOfPage" to this specific site?
Asked Answered
A

1

20

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.

Ariannearianrhod answered 25/12, 2015 at 20:8 Comment(0)
S
53

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.)

Socialistic answered 25/12, 2015 at 22:50 Comment(8)
Thank you for all these details. What about my specific example? There I have <article itemprop="blogPost" itemscope="" itemtype="https://schema.org/BlogPosting"> Should I remove itemprop="blogPost" from that and create something like this: <article itemscope itemtype="https://schema.org/BlogPosting"> <link itemprop="mainEntityOfPage" href="https://linktoarticle" />Ariannearianrhod
@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).Socialistic
So you are saying that it's good to have two itemprop in the same section and have it like this: <article itemprop="blogPost" itemscope="" itemtype="https://schema.org/BlogPosting"> <link itemprop="mainEntityOfPage" href="https://linktoarticle" /> ?Ariannearianrhod
@Pikk: Sure. It’s not different to having, for example, <h1 itemprop="name">Foo</h1> 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.Socialistic
Thank you. Much appreciatedAriannearianrhod
See if seoskeptic.com/… makes any sense. What solution did you use in the end? I'm in the same boat.Ingvar
Respect for the properly validating <link itemprop="mainEntityOfPage"... instead of the Google suggested <meta itemprop="mainEntityOfPage"...Atrioventricular
@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.Rations

© 2022 - 2024 — McMap. All rights reserved.