Mobile app version of vmapp.org
Login or Join
Martha676

: How to embed a Schema.org data type? 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/)

@Martha676

Posted in: #Html5 #Microdata #SchemaOrg

How to embed items of a different data type? Schema.org explains it here: 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>



Why Google’s markup helper gives itemprop="name", is it an error?
Are my solutions ok?
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 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?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Martha676

2 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

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.

10% popularity Vote Up Vote Down


 

@Alves908

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme