partiz
partiz

Reputation: 1216

Write Microdata just with <link> and <meta>

How to write this Microdata code

<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    <span itemprop="ratingValue">4.6</span> (
    <span itemprop="ratingCount">8864</span> ratings )
  </div>

  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    Price: $<span itemprop="price">1.00</span>
    <meta itemprop="priceCurrency" content="USD" />
  </div>

as <link …> or <meta …>? I do not have HTML tag in my page.

Upvotes: 1

Views: 393

Answers (1)

unor
unor

Reputation: 96737

If the value is a URI, use link. Otherwise, use meta.

So <span itemprop="ratingValue">4.6</span> becomes <meta itemprop="ratingValue" content="4.6" /> etc.

If it’s just about having no visible content, you could keep using the parent div elements, e.g.:

<div itemscope> <!-- you can/should give it an itemtype -->

  <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    <meta itemprop="ratingValue" content="4.6" />
    <meta itemprop="ratingCount" content="8864" />
  </div>

  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <meta itemprop="price" content="1.00" />
    <meta itemprop="priceCurrency" content="USD" />
  </div>

</div>

If you also want to omit these div elements, you’d have to use the itemref attribute, because you can’t nest elements under link/meta. And because meta elements used for Microdata require the itemprop attribute, you have to use one parent element (e.g., div, body, html) to specify an itemscope:

<body itemscope> <!-- you can/should give it an itemtype -->

  <meta itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" content="" itemref="my-rv my-rc">
  <meta itemprop="ratingValue" content="4.6" id="my-rv" />
  <meta itemprop="ratingCount" content="8864" id="my-rc" />

</body>

Having said that, if you generally don’t want to markup your existing/visible content, you might want to use JSON-LD instead of Microdata or RDFa.

Upvotes: 3

Related Questions