1

How to embed items of a different data type? Schema.org explains it here: https://schema.org/docs/gs.html

I use Google’s markup helper (www.google.com/webmasters/markup-helper/) that creates automatically the code. I have this code simplified and I choose data type Article:

<div class="post">
<img src="1.png">
<h1>Title of the post</h1>  
<div>       
    <p>This is the body of the post</p>
</div>  
<p>Author of the post</p>
</div><!-- end schema Article -->

Google gives me this:

<div itemscope itemtype="http://schema.org/Article">
<img itemprop="image" src="1.png">
<h1 itemprop="headline name" >Title of the post</h1>
<div itemprop="articleBody" >       
    <p>This is the body of the post</p>
</div>
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
<p itemprop="name">Author of the post</p>
</span>
</div><!-- end schema Article -->

I am confused on the last span. I understand that author belongs to the data type Person and not Article. But why it introduces the itemprop="name" here? It seems redundant. For me, one of those options makes more sense:

<p itemprop="author" itemscope itemtype="http://schema.org/Person">
Author of the post
</p>

Or perhaps:

<span itemscope itemtype="http://schema.org/Person">
<p itemprop="author">Author of the post</p>
</span>
  1. Why Google’s markup helper gives itemprop="name", is it an error?
  2. Are my solutions ok?
  3. Can anyone explain in a simple way how to embed a different data type in Schema.org?

(Where I write "Author of the post" I mean any name, John Doe, for instance)

UPDATE:

Now I realize that Schema Article (Blog and BlogPosting too) do have the property Autor. In fact https://schema.org/Article Example 1 (bottom of the page) gives this:

<div itemscope itemtype="http://schema.org/Article">
  <span itemprop="name">How to Tie a Reef Knot</span>
  by <span itemprop="author">John Doe</span>
</div>

So, I suppose that there is no need to embed author from Person. Google’s markup helper must have a software problem. Am I right?

1

The HTML is not correct, because a span can’t have a p as child. It should probably be a div, i.e.:

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

  <div itemprop="author" itemscope itemtype="http://schema.org/Person">
    <p itemprop="name">Author of the post</p>
  </div>

</div>

The problem you seem to have is likely the same one from your comment to my answer to your other question.

How Microdata works

I think you have to understand how Microdata works:

  • The itemscope attribute creates an item.

    (Here is something.)

  • The itemtype attribute specifies the type of that item.

    (This something is a Person.)

  • The itemprop attribute specifies the property this item has.

    (This something, which is a Person, has the name "Alice".)

The ìtemprop always belongs to the nearest itemscope parent! So in your example, the author property does not belong to the Person item, it belongs to the Article item.
It says: Here is an Article. This Article has an author, which is a Person. This Person has a name.

Your first suggestion

<p itemprop="author" itemscope itemtype="http://schema.org/Person">
Author of the post
</p>

You provide the author property, and you say that the author is a Person (good), but then you don’t provide any property about that Person. How should a consumer know that the element content ("Author of the post") is the name of that person, and not the person’s address/birthday/description/etc.? (Schema.org’s Person type can have many properties.)

Microdata ignores any content that is not an itemprop value. The value of the author property in your suggestion is the Person item, not the string "Author of the post". A Microdata parser will never see that string (unless you put it as value to an itemprop).

Your second suggestion

<span itemscope itemtype="http://schema.org/Person">
<p itemprop="author">Author of the post</p>
</span>

This means: There is a Person which is authored by "Author of the post".

But the Person has no author, of course. (And Schema.org doesn’t define an author property for Person.)

Another problem: For consumers it’s not clear that this Person represents the author of the Article. You have to use an itemprop attribute to "add" it to the Article.

A possible alternative (not recommended)

Instead of

<div itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p itemprop="name">Author of the post</p>
</div>

you could use

<div itemprop="author">Author of the post</div>

but it’s not recommended/expected (by Schema.org).

The key difference here is that this author property has text (instead of another item!) as value. The obvious problem of using a text value: You can’t provide more information (in the form of properties) about this author (e.g., the author’s website URL, etc.).

Why it’s not recommended? Because Schema.org’s author property is defined to get an Organization or a Person value.

  • see my update. Schema do not embed author when it is in Article – Nrc Aug 24 '16 at 10:50
  • @Nrc: The snippet from your update is what I described under the heading "A possible alternative (not recommended)" in my answer. It’s technically possible in Microdata, and Schema.org says that it’s better than not providing the author at all, but it’s not an expected value, so various consumers (including validators etc.) might not support it. -- The citation property is an example that can either have an item as expected value (CreativeWork) or text as an expected value, but for author this is not the case (the only expected values are items). – unor Aug 24 '16 at 11:03
0

If you're familiar with XML it's very similar:

Each element or 'Item' has a list of possible attributes or 'Properties'. Child elements carry the property values. Properties can then have properties, which are in their children.

The Author is an 'Item' of type 'Person'. The value of it's properties is set by the text in the Name element. This property is inherited from it's parent item 'Thing' - which has a list of properties that can be assigned to all it's types. Name can be applied to any property under 'Thing'.

Further reading on Itemscopes.

  • But to introduce here name seems redundant. Are my solutions correct? they seem more direct and simpler to me – Nrc Aug 23 '16 at 15:16
  • Schema doesn't care what's simpler. It works on a tree structure, as defined by the document. It's designed to bring structure to unordered data. – L Martin Aug 23 '16 at 15:51
  • see my update. Schema do not embed author when it is in Article – Nrc Aug 24 '16 at 10:51

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.