11

I had a look at the article structured data as proposed by Google and saw that there are a new required and recommended fields, they weren't there last week. Here is the link:

https://developers.google.com/structured-data/rich-snippets/articles

The first property on the list is :

  • mainEntityOfPage.@id (recommended)

I don't understand what the value of the property must be? What is this property? Is it a link to:

..or a link to the current blog post like:

They have this in their sample code:

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

This what I currently have, it does not yet conform to the test tool's rules - I am still busy adding all the required properties and at the same time trying to add the recommended properties there as well:

<div itemscope itemtype="http://schema.org/BlogPosting">
   <h1 itemprop="headline">
      <a href="http:///www.example.com/blog/1001/my-blog-article" itemprop="url">My Blog Article</a>
   </h1>
   <p>Written by
      <span itemprop="author" itemscope itemtype="http://schema.org/Person">
         <span itemprop="name">Mase Kind</span>
      </span> on
      <time itemprop="datePublished" datetime="2015-11-16T15:30:00+02:00">November 16, 2015</time>
      <meta itemprop="dateModified" content="2015-12-10T12:29:00+02:00" />
      <div itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
         <div itemprop="logo" itemscope itemtype="http://schema.org/ImageObject"></div>
         <meta itemprop="name" content="My Company Name" />
      </div>
   </p>
   <div itemprop="articleBody">
      <p>first article body</p>
   </div>
</div>

I also have this in my document:

<body itemscope itemtype="http://schema.org/WebPage">
...
</body>

Will this in any way conflict with the code sample supplied by Google?

  • Just saw the same thing happen to my site this morning and landed on this thread. – dasickle Dec 15 '15 at 18:14
11

The mainEntityOfPage property is used to give the URL of a page on which the thing is the main entity. It might become clearer if you look at the inverse property mainEntity: this gives the main entity for a page (see an example).

For example, for a web page that contains a single blog post, you could provide one of these:

  • BlogPostingmainEntityOfPageWebPage
  • WebPagemainEntityBlogPosting

These properties are useful to convey what the main content on a page is (because pages might contain multiple items, e.g., an ItemList with related WebPage items, a Person describing the author, a WebSite giving some metadata, etc.).

(See my answer on Stack Overflow for a more detailed explanation.)


There are two ways how to use mainEntityOfPage:

  • provide the URL of the page
  • embed/reference the page item (typically a WebPage)

The second one often doesn’t make much sense (you would rather use the inverse property mainEntity), and probably for that reason Google recommends/expects the first one.

For providing the URL, you could simply use a link element:

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

Google’s Structured Data Testing Tool accepts this.

In the Articles Rich Snippet example, Google is using a meta element with itemid instead:

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

This is invalid HTML5+Microdata: If the meta element has an itemprop attribute, it must also have a content attribute.

  • what if we also provide content with url in meta, e.g. <meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="https://google.com/article" content='https://google.com/article' /> It'll validate fine and not showing error in structured data testing tool – StarWars Apr 1 '17 at 17:44
  • @StarWars: Yes, that’s the way to make this meta element valid. Note that the content value would be ignored, so you could provide an empty value. – unor Apr 1 '17 at 18:00
  • okay, I've now added content="" to meta tag. – StarWars Apr 1 '17 at 18:54
  • Why google uses meta instead of link in its examples? both of these validate in the structured data testing tool. Although, the preview is different. When link is used, it has mainEntityOfPage http://example.com/article-1 while in the case of meta it shows @id and @type attributes. – StarWars Apr 1 '17 at 19:07
  • @StarWars: Yes, that’s exactly the difference: the meta way creates a new item with a type and a URI as identifier, the link way just links to a page. I have no idea why Google’s documentation uses meta, especially since I think the link way is more simple. – unor Apr 1 '17 at 19:20
2

What is this property?

It's supplementary to the url and sameAs properties, as described in the mainEntity background.

It has an idiosyncratic name as it may be applied to all items of type Thing. If it applied only to Articles it could have been called mainTopic/mainTopicOfArticle and been more clear.

I don't understand what the value of the property must be?

The value of the property is expected to be a item of type CreativeWork or a URL referencing that work according to Schema.org. That means it could also be an Article or BlogPosting as you mentioned. However, if you're building out AMP pages, the value should be a URL.

Will this in any way conflict with the code sample supplied by Google?

Despite what Google's Structured Data Testing Tool says their documentation no longer recommends using the mainEntityOfPage for non-AMP pages so you're free to omit it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.