Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you format keywords in Microdata for a CreativeWork?

I'm working with Microdata and I want to use Schema.org’s keywords for CreativeWork.

The schema specifies that it should be text but do I put each keyword in a separate element with itemprop="keywords" or do I put them all in one keywords element? If I put them all in one element do I use commas as a separator?

like image 267
Last Rose Studios Avatar asked Nov 07 '11 16:11

Last Rose Studios


3 Answers

You should create an itemprop element for each keyword as follows:

<div itemscope itemtype="http://schema.org/CreativeWork">
  <span itemprop="name">Resistance 3: Fall of Man</span>
  by <span itemprop="author">Sony</span>.
  Keywords:
  <a href="/tags/game/"><span itemprop="keywords">Game</span></a>,
  <a href="/tags/adult/"><span itemprop="keywords">Adult</span></a>
</div>
like image 180
Lawrence Woodman Avatar answered Nov 04 '22 15:11

Lawrence Woodman


The definition of Schema.org’s keywords property changed. It now reads:

Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas.

So it could look like this in Microdata:

<article itemscope itemtype="http://schema.org/BlogPosting">

  <footer>
    <ul itemprop="keywords">
      <li><a href="/tags/foo" rel="tag">foo</a>,</li>
      <li><a href="/tags/bar" rel="tag">bar</a></li>
    </ul>
  </footer>

</article>

(Example taken from my related answer about semantic markup for tags.)

If you don’t want to have commas visible on the page, you could use a meta element in addition to your normal markup for the tags:

<meta itemprop="keywords" content="foo, bar" />

(It’s allowed to place this meta element in the `body´.)

like image 38
unor Avatar answered Nov 04 '22 15:11

unor


My reading of the specification leads me to the conclusion that you can have just one itemprop attribute per property.

In other words, i don't think that creating an itemprop element for each keyword will create a correct microdata syntax.

I would put each keyword in a space-separated list, and use a single itemprop:

  <span itemprop="keywords">
  <a href="/tags/game/">Game</a>,
  <a href="/tags/adult/">Adult</a>
  </span>

or

 <meta itemprop="keywords" content="Game Adult"/>

i am not sure what should be done in case a keyword contains multiple words, since there is nothing in the specification that says how keywords should be separated in the text (i assume by spaces and.or punctuation like comma).

@Lawrence Woodman : could you indicate where you read, in the specification, that it is allowed to have multiple itemprop elements for the same property?

like image 43
user2469270 Avatar answered Nov 04 '22 16:11

user2469270