How to mark only product categories?

℡╲_俬逩灬. 提交于 2019-12-13 04:56:41

问题


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>

回答1:


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.)



来源:https://stackoverflow.com/questions/22990678/how-to-mark-only-product-categories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!