Search code examples
htmlschema.orgmicrodatastructured-data

Setting the service details for several reviews with structured data


I'm doing up a testimonials page and recently I have been utilising structured data to help SE's find the reviews more easily; as per the review information found.

Now, normally if I was doing one review I would do something like this:

<div itemscope itemtype="http://schema.org/Review">
    <div itemprop="itemReviewed" itemscope itemtype="http://schema.org/Service">
        <span itemprop="provider">Business Name</span>
        <span itemprop="serviceType">Service Provided</span>
        <span itemprop="url">http://www.example.com/</span>
    </div>
    <div class="review" itemprop="reviewBody">Great service - thanks!</div>
    <div class="other">
        <p class="name" itemprop="author">Joey Bigs</p>
        <p class="details">Owner, <a href="">Joes Treats</a></p>
    </div>
</div>

Now, what if I wanted to do a page that had several reviews for the same thing; do I need to repeat the below information for each review or can I just display it once?

    <div itemprop="itemReviewed" itemscope itemtype="http://schema.org/Service">
        <span itemprop="provider">Business Name</span>
        <span itemprop="serviceType">Service Provided</span>
        <span itemprop="url">http://www.example.com/</span>
    </div>

If I only need to include it once - how do I go about doing this?


Solution

  • You can use Microdata’s itemref attribute to reference the item that gets reviewed, so you don’t have to repeat it for each review:

    <div id="foo" itemprop="itemReviewed" itemscope itemtype="http://schema.org/Service">
      <!-- make sure that this element is not a child of another itemscope -->
    </div> 
    
    <div itemscope itemtype="http://schema.org/Review" itemref="foo"></div>
    
    <div itemscope itemtype="http://schema.org/Review" itemref="foo"></div>
    
    <div itemscope itemtype="http://schema.org/Review" itemref="foo"></div>