10

Let's say I have the mark-up like this:

<ul id="comments">

  <li class="comment"> 
    <div class="author">on Friday 3th, Jenny said:</div>
    <div class="content"><p>bla bla</p></div> 
  </li>

  <li class="comment"> 
    <div class="author">on Friday 3th, Jenny said:</div>
    <div class="content"><p>bla bla</p></div> 

    <ul class="level-2">
      <li class="comment"> 
        <div class="author">on Friday 3th, Mary said:</div>
        <div class="content">stfu jenny</div> 
      </li>       
    </ul>
  </li>
  ...

How do I use the "UserComments" item on this mark-up ? http://schema.org/UserComments

Where do I add itemscope itemtype="http://schema.org/UserComments" ? Once on the list container, or multiple times on each list item?

unor
  • 92,415
  • 26
  • 211
  • 360
Alex
  • 66,732
  • 177
  • 439
  • 641

4 Answers4

8

You shouldn't be using itemprop="name", but instead use "creator".

More examples... http://homebiss.blogspot.com/2011/11/schema-markups-blogger-comments.html

MTT
  • 327
  • 1
  • 5
  • 16
7

According to the HTML5 Microdata typed items specs, you would add it to the container of your comments section, e.g.

<section itemscope itemtype="http://example.org/animals#cat">
 <h1 itemprop="name">Hedral</h1>
 <p itemprop="desc">Hedral is a male american domestic
 shorthair, with a fluffy black fur with white paws and belly.</p>
 <img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months">
</section>

So the item scope for your comment section would be formatted like this (taking into account the item properties):

<ul id="comments" itemscope itemtype="http://schema.org/UserComments">

  <li class="comment"> 
    <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Jenny said:</div>
    <div itemprop="commentText" class="content"><p>bla bla</p></div> 
  </li>

  <li class="comment"> 
    <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Jenny said:</div>
    <div itemprop="commentText" class="content"><p>bla bla</p></div> 

    <ul class="level-2">
      <li class="comment"> 
        <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Mary said:</div>
        <div itemprop="commentText" class="content">stfu jenny</div> 
      </li>       
    </ul>
  </li>
...
Andres I Perez
  • 75,075
  • 21
  • 157
  • 138
  • 1
    As mattrepublic said below, an author is tagged using the "creator" property, not "name" doc says: _This is the same as the Author property for CreativeWork_. Plus, it's always better to use appropriate tags, when possible, so in this case, – SuN Dec 10 '13 at 09:11
  • 4
    This is **not correct**. Each comment needs to be an own/separate item. In your code, there would only be *one comment* with several different names/times/texts. – unor Apr 03 '14 at 15:31
6

Each comment would be an own item (UserComments in your example). You might also want to use an article element for each comment.

<article itemscope itemtype="http://schema.org/UserComments">
  <header>
    on 
    <time itemprop="commentTime" datetime="…">Friday 3th</time>, 
    <span itemprop="creator" itemscope itemtype="http://schema.org/Person">
      <span itemprop="name">Jenny</span>
    </span> 
    said:
  </header>
  <p itemprop="commentText">bla bla</p>
</article>

However, now there is also Comment, which seems to be more appropriate because it’s a CreativeWork (and not an Event, like UserComments).

unor
  • 92,415
  • 26
  • 211
  • 360
0

Due to schema.org, It is good to change using userComments to Comment:

UserInteraction and its subtypes is an old way of talking about users interacting with pages. It is generally better to use Action-based vocabulary, alongside types such as Comment.

But you can use this item by adding commentText property and creator as a person to it.

Amir Fo
  • 5,163
  • 1
  • 43
  • 51