0

How do I have to mark my website product categories? … only categories …

Maybe with category from Offer?

Something like:

<div itemscope itemtype="http://schema.org/Offer">
   <a itemprop="category" href="category1.php">My category 1</a>
</div>
unor
  • 92,415
  • 26
  • 211
  • 360
mdromed
  • 49
  • 7

1 Answers1

4

You should not specify category on an a element. The value would be the URI (category1.php), not the content (My category 1).

category expects a value that is either text or another item.

So if you want to provide text, you could use something like:

<div itemscope itemtype="http://schema.org/Offer">
   <a href="category1.php"><span itemprop="category">My category 1</span></a>
</div>

And yes, it is totally fine to use only one property. Schema.org doesn’t define required properties. But consumers (e.g., search engines) might, of course, only consider re-using your data if it fulfils certain of their own requirements.


UPDATE: If you want to provide several categories for the item, it could be something like:

<div itemscope itemtype="http://schema.org/Offer">
  <ul>
   <li itemprop="category"><a href="category1.php">My category 1</a></li>
   <li itemprop="category"><a href="category2.php">My category 2</a></li>
   <li itemprop="category"><a href="category3.php">My category 3</a></li>
  </ul>
</div>

Don’t rename the category property! Adding 1, 2 etc. to it would be wrong.

(And it it’s a hierarchy of categories, you could use one value and / or >., e.g. Sports > Tennis.)

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • ok @unor, but if i have many categories must put different itemscope to make that or put all into only itemscope block? like... `
    My category 1My category 2My category 3
    `
    – mdromed Apr 10 '14 at 16:03
  • @mdromed: I added an example to my answer. – unor Apr 10 '14 at 16:09
  • Ok perfect @unor. Then ([in my other question](http://stackoverflow.com/questions/22990049/2-itemprops-for-2-colors-of-the-same-product)) with `color` itemprops would be the same? And...Is it valid in Google testing tool, repeating itemprop items? – mdromed Apr 10 '14 at 16:13
  • @mdromed: It’s valid Microdata. Google would probably understand it, too. But if they like it or not (i.e., if or how they re-use your markup) is a SEO question which is off-topic for Stack Overflow. – unor Apr 10 '14 at 16:18
  • @mdromed: You’re welcome. Two more meta things: **a)** When commenting, the `@username` part must be the first thing in your comment, otherwise it would not notify the person in all cases. **b)** You may accept my answer if it answered your question :) – unor Apr 10 '14 at 16:22
  • @mdromed: I know, you need at least 15 reputation to vote. But you can still accept my answer (by clicking at the checkmark below the voting buttons). – unor Apr 10 '14 at 16:36