Mobile app version of vmapp.org
Login or Join
Pope3001725

: Can I use same 'itemtype' in Microdata twice? I have an element in my website that shows the last updates of my website. My current structure of the website is this: <body itemscope itemtype="http://schema.org/webpage"

@Pope3001725

Posted in: #Html5 #Microdata #SchemaOrg

I have an element in my website that shows the last updates of my website.

My current structure of the website is this:

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

<div itemscope itemtype="http://schema.org/WPSideBar>
<div>...some text...</div>
<div>last update: 23/1/2014</div> //last update for whole site
<div/>

</body>


The 'last update' is for the whole website, not for the sidebar!
Can I use itemtype twice to solve this problem?

For example, do you think this is correct?

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

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

<div>...some text...</div>
<div itemscope itemtype="http://schema.org/webpage">
<span itemscope="name">last update: </span>
<time itemprop="datePublished" datetime="2014-01-23 13:52:00">23/1/2014</time>
</div>
<div/>

</body>

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Pope3001725

2 Comments

Sorted by latest first Latest Oldest Best

 

@Pierce454

You can use the same element or schema more than once, for example having multiple Products in one webpage, but in this situation you would be incorrectly marking up that TWO WebPage elements are on the page. Instead you need to have just one, but cope with WPSideBar in the middle. Based on your description dateModified sounds a better choice than datePublished too. This code uses hasPart to nest WPSideBar inside WebPage.

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

<div itemprop="hasPart" itemscope itemtype="http://schema.org/WPSideBar">
<div>...some text...</div>
<span itemscope="name">last update: </span>
<meta itemprop="dateModified" content="2014-01-23 13:52:00"/>
<time>23/1/2014</time> //last update for whole site
</div>
</div>
</body>


Result from structured data tester

WebPage
hasPart [WPSideBar]:
dateModified: 2014-01-23T13:52:00


This sets the dateModified of WPSideBar only. It would be more sensible to set the date for WebPage Element only which can be done by removing this WPSideBar line from the code above and the <span> tag, which isn't doing anything but naming the sidebar:

<div itemprop="hasPart" itemscope itemtype="http://schema.org/WPSideBar>


If the two dates could be different then you can keep the line above in, and use the code

<body itemscope itemtype="http://schema.org/WebPage"><meta itemprop="dateModified" content="2014-01-20 00:00:00"/>
<div itemprop="hasPart" itemscope itemtype="http://schema.org/WPSideBar">
<div>...some text...</div>
<span itemscope="name">last update: </span>
<meta itemprop="dateModified" content="2014-01-23 13:52:00"/>
<time>23/1/2014</time> //last update for whole site
</div>
</div>
</body>


Google structured data testing result

WebPage
dateModified: 2014-01-20T13:00:00
hasPart [WPSideBar]:
dateModified: 2014-01-23T13:52:00


Without the hasPart property

WebPage
dateModified: 2014-01-20T13:00:00

WPSideBar
dateModified: 2014-01-23T13:52:00


Explanation
WPSideBar is a WebPageElement, which can be linked to (nested inside) the WebPage by using itemprop="hasPart" - this is a property inherited from CreativeWork. This is nesting of structured data.

Your date is a non-standard format so I've used a Non-visible self-closing meta tag to represent this date in the right format, this is one of the allowed reasons for having hidden structured data. You originally had "datetime" in place of "content".

Several syntax errors were in the original code including unclosed <body> tag, next time use a HTML validator/linter before creating a structured data question - it saves lots of work sorting out structured data errors that turn out not to be caused by structured data.

10% popularity Vote Up Vote Down


 

@Ogunnowo487

No, you should not add several items which are about the same thing on the same page.

If the datePublished is the publication date for your whole page, it has to be nested under WebPage and not under WPSideBar.

You could use the itemref attribute if you can’t nest it directly under WebPage, but you’d still have to remove it from WPSideBar. Unless you want this date to be associated with the WPSideBar in addition. If that’s the case, you could use:

<!-- here the 'datePublished' applies to both, the WebPage *and* the WPSideBar -->
<div itemscope itemtype="http://schema.org/WebPage" itemref="foobar">

<div itemscope itemtype="http://schema.org/WPSideBar">
<time itemprop="datePublished" datetime="2014-01-23 13:52:00" id="foobar">23/1/2014</time>
</div>

</div>


(Note that it’s schema.org/WebPage, not schema.org/webpage.)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme