如何用Schema.org标注食品的营养信息?

How to mark up food product's nutritional information with Schema.org?

我正在寻找一种方法来标记食品产品营养信息 Schema.org (JSON-LD、微数据或 RDFa)。到目前为止,我的尝试无法在 Google's Structured data testing tool.

中验证

"food product" 我的意思是像一盒 麦片 一盒 橙汁.

不幸的是,根据此页面 http://schema.org/nutrition, 仅 MenuItem and Recipe types. Neither of these 2 options feel correct to me in this case. Perhaps an argument could be made for MenuItem.

明确支持营养信息标记

我还没有遇到标记食品营养的示例网站,所以我不确定目前是否有解决方案 [2017 年 6 月 13 日]。


Google's Structured data testing tool:

上测试时导致错误的尝试的简化 JSON-LD 示例
<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Product",
    "name": "Orange Juice 250ml",
    "nutrition": {
      "@type": "NutritionInformation",
      "calories": "X calories"
    }
  }
</script>

产生的错误:

The property nutrition is not recognised by Google for an object of type Product.

Schema.org 还没有适合您的用例的type/property。

  1. NutritionInformation type can only be added with the nutrition 属性。
  2. nutrition 属性 只能添加到 MenuItem and Recipe 类型。

如果您可以将食品表示为菜单项,则可以同时使用 MenuItemProduct

"@type": ["Product", "MenuItem"],

Google 的 SDTT 不会报告错误,只要至少一种指定类型允许 属性.

但也许您一开始就不需要 Product。您可以直接将 Offer 添加到 MenuItem(使用 offers 属性)。


Schema.org 将来可能会引入 Food(或类似名称)类型。查看他们的问题 Create a new Food type (help further with foodWarning and recipeIngredient).