Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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>
share|improve this question

2 Answers 2

up vote 0 down vote accepted

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 http://schema.org/WebPage, not http://schema.org/webpage.)

share|improve this answer
    
@Mousey: Did you meant to make this comment under OP’s question instead of my answer? –  unor Jul 29 at 14:30
    
@Mousey: But this question is not about how WPSideBar could be referenced from WebPage (e.g., with the hasPart property, which didn’t exist when OP asked the question). It’s about the datePublished property. My code creates one (not two)WebPage item and one WPSideBar item, and both have the same datePublished property. –  unor Jul 29 at 15:37
    
@Mousey: I agree that it’s a good practice to link the items with appropriate properties (and if the hasPart property would have existed back then, I’d have probably suggested it), but in my snippet the WebPage has the date (from datePublished) because of the itemref attribute. –  unor Jul 29 at 16:02
    
sorry did not realized this was a full 12 months old @unor –  Mousey Jul 29 at 16:04
1  
@Mousey: No problem! And it’s always good to comment on old (as well as new) answers to note/correct/improve something. I just wanted to make sure that we’re on the same page here. –  unor Jul 29 at 16:07

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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