【发布时间】:2016-08-04 14:32:54
【问题描述】:
有没有办法描述餐厅菜单中每道菜的属性?
这些字段尤其是:名称、描述、价格
或者当您在餐厅属性中指明菜单的 url 时,是否必须祈祷 google 正确解释数据?
【问题讨论】:
标签: schema.org structured-data google-knowledge-graph
有没有办法描述餐厅菜单中每道菜的属性?
这些字段尤其是:名称、描述、价格
或者当您在餐厅属性中指明菜单的 url 时,是否必须祈祷 google 正确解释数据?
【问题讨论】:
标签: schema.org structured-data google-knowledge-graph
这真是个好消息!所以,在这里我要分享一些我自己等了很久的东西。
如果您一直在梦想一种适当的方法,该方法允许标记多个餐厅菜单以及菜单部分甚至提供差异化,那么您会惊讶于刷新后的 schema.org/restaurant 结构化标记的可能性。
当您访问schema.org/Restaurant 页面时,您首先会注意到 menu 属性已被 hasMenu 属性替换,该属性现在取代了仍然有效的菜单之一。
那么,直截了当:
在网站的每个页面上,建议将搜索引擎指向正确的方向,以找到菜单的位置。这是nice article,涵盖了我在这里整理的大部分内容。
Google 的指导方针规定,我们应该只标记页面上可见的内容,我们不能将整个菜单完全包含在我们的主页标记中,除非整个菜单都在那里发布。相反,我们将简单地使用主页上的 hasMenu 属性指向菜单页面,如下所示:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"name": "Your Restaurant's Name",
"url": "http://your-restaurant.com/",
"publisher": {
"@type": "Restaurant",
"name": "Your Restaurant's Name",
"hasMenu": "http://your-restaurant.com/menu/",
"logo": "http://.....
事实上,在您网站的任何包含一些架构标记的页面上,您都可以使用 hasMenu 属性指向菜单页面的 URL。
当您有多个菜单时:
“hasMenu”: [
{
“@type”: “Menu”,
“name”: “Breakfast”,
“url”: “http://your-restaurant.com/breakfast-menu/”
},
{
“@type”: “Menu”,
“name”: “Lunch”,
“url”: “http://your-restaurant.com/lunch-menu/”
},
{
“@type”: “Menu”,
“name”: “Dinner”,
“url”: “http://your-restaurant.com/dinner-menu/”
}
],
...
将注意力转移到实际的菜单页面,假设菜单仅在下午 5:00 到晚上 11:00 之间提供。所以,在菜单页面上,我们的标记会这样开始:
<script type=”application/ld+json”>
{
“@context”: “http://schema.org”,
“@type”: “Menu”,
“name”: “Our Menu”,
“mainEntityOfPage”: “http://your-restaurant.com/menu/”,
“inLanguage”: “English”,
“offers”: {
“@type”: “Offer”,
“availabilityStarts”: “T17:00”,
“availabilityEnds”: “T23:00”
},
接下来,我们可以开始标记菜单的各个部分和各个菜单项。首先,我们将从开胃菜开始。对于第一个开胃菜,我们将在标记中包含名称、简短描述和价格,这应该是任何菜单项的最低价格。在我们的第二个开胃菜标记示例中,我们还将包含一张图片、营养信息以及它不含麸质的事实:
“hasMenuSection”: [
{
“@type”: “MenuSection”,
“name”: “Appetizers”,
“hasMenuItem”: [
{
“@type”: “MenuItem”,
“name”: “Fried Eggplant”,
“description”: “Served with Italian red gravy.”,
“offers”: {
“@type”: “Offer”,
“price”: “7.95”,
“priceCurrency”: “USD”
}
},
{
“@type”: “MenuItem”,
“name”: “Fried Calamari”,
“description”: “Served with Italian red gravy or honey mustard.”,
“image”: “http://your-restaurant.com/images/fried-calamari.jpg”,
“suitableForDiet”: “http://schema.org/GlutenFreeDiet”,
“nutrition”: {
“@type”: “NutritionInformation”,
“calories”: “573 calories”,
“fatContent”: “25 grams”,
“carbohydrateContent”: “26 grams”,
“proteinContent”: “61 grams”
},
“offers”: {
“@type”: “Offer”,
“price”: “7.95”,
“priceCurrency”: “USD”
}
}
]
},
假设我们已经标记了所有的开胃菜,我们准备开始标记下一个菜单部分,在我们的例子中是汤。有时,汤等菜单项有两种或多种尺寸可供选择。我们可以通过为每个选项使用单独的报价标记以及合格数量属性来标记可用选项,如下所示:
{
“@type”: “MenuSection”,
“name”: “Soups”,
“hasMenuItem”: [
{
“@type”: “MenuItem”,
“name”: “Lobster Bisque”,
“offers”: [
{
“@type”: “Offer”,
“price”: “6.75”,
“priceCurrency”: “USD”,
“eligibleQuantity”: {
“@type”: “QuantitativeValue”,
“name”: “Cup”
}
},
{
“@type”: “Offer”,
“price”: “9.95”,
“priceCurrency”: “USD”,
“eligibleQuantity” : {
“@type”: “QuantitativeValue”,
“name”: “Bowl”
}
}
]
},
{
“@type”: “MenuItem”,
“name”: “Creole Seafood Gumbo”,
“offers”: [
{
“@type”: “Offer”,
“price”: “6.75”,
“priceCurrency”: “USD”,
“eligibleQuantity”: {
“@type”: “QuantitativeValue”,
“name”: “Cup”
}
},
{
“@type”: “Offer”,
“name”: “Bowl”,
“price”: “9.95”,
“priceCurrency”: “USD”,
“eligibleQuantity” : {
“@type”: “QuantitativeValue”,
“name”: “Bowl”
}
}
]
}
]
},
标记完所有汤品后,我们可以继续使用相同格式标记其他菜单部分和项目。就是这样。综上所述,我们的 JSON-LD 菜单标记看起来像这样:
<script type=”application/ld+json”>
{
“@context”:”http://schema.org”,
“@type”:”Menu”,
“name”: “Our Menu”,
“url”: “http://your-restaurant.com/menu/”,
“mainEntityOfPage”: “http://your-restaurant.com/menu/”,
“inLanguage”:”English”,
“offers”: {
“@type”: “Offer”,
“availabilityStarts”: “T17:00”,
“availabilityEnds”: “T23:00”
},
“hasMenuSection”: [
{
“@type”: “MenuSection”,
“name”: “Appetizers”,
“hasMenuItem”: [
{
“@type”: “MenuItem”,
“name”: “Fried Eggplant”,
“description”: “Served with Italian red gravy.”,
“offers”: {
“@type”: “Offer”,
“price”: “7.95”,
“priceCurrency”: “USD”
}
},
{
“@type”: “MenuItem”,
“name”: “Fried Calamari”,
“description”: “Served with Italian red gravy or honey mustard.”,
“image”: “http://your-restaurant.com/images/fried-calamari.jpg”,
“suitableForDiet”: “http://schema.org/GlutenFreeDiet”,
“nutrition”: {
“@type”: “NutritionInformation”,
“calories”: “573 calories”,
“fatContent”: “25 grams”,
“carbohydrateContent”: “26 grams”,
“proteinContent”: “61 grams”
},
“offers”: {
“@type”: “Offer”,
“price”: “7.95”,
“priceCurrency”: “USD”
}
}
]
},
{
“@type”: “MenuSection”,
“name”: “Soups”,
“hasMenuItem”: [
{
“@type”: “MenuItem”,
“name”: “Lobster Bisque”,
“offers”: [
{
“@type”: “Offer”,
“price”: “6.75”,
“priceCurrency”: “USD”,
“eligibleQuantity”: {
“@type”: “QuantitativeValue”,
“name”: “Cup”
}
},
{
“@type”: “Offer”,
“price”: “9.95”,
“priceCurrency”: “USD”,
“eligibleQuantity” : {
“@type”: “QuantitativeValue”,
“name”: “Bowl”
}
}
]
},
{
“@type”: “MenuItem”,
“name”: “Creole Seafood Gumbo”,
“offers”: [
{
“@type”: “Offer”,
“price”: “6.75”,
“priceCurrency”: “USD”,
“eligibleQuantity”: {
“@type”: “QuantitativeValue”,
“name”: “Cup”
}
},
{
“@type”: “Offer”,
“name”: “Bowl”,
“price”: “9.95”,
“priceCurrency”: “USD”,
“eligibleQuantity” : {
“@type”: “QuantitativeValue”,
“name”: “Bowl”
}
}
]
}
]
},
{
“@type”: “MenuSection”,
“name”: “Pastas”,
“description”: “Entrées served with dinner salad or a cup of soup of the day.”,
“hasMenuItem”: [
{
“@type”: “MenuItem”,
“name”: “Veal Parmigiana”,
“description”: “Tender cuts of paneed veal crowned with golden fried eggplant, Italian red gravy, mozzarella, and parmesan; served with spaghetti.”,
“offers”: {
“@type”: “Offer”,
“price”: “17.95”,
“priceCurrency”: “USD”
}
},
{
“@type”: “MenuItem”,
“name”: “Eggplant Parmigiana”,
“description”: “Pan fried eggplant layered and topped with Italian red gravy, mozzarella, and parmesan baked until bubbly; served with spaghetti.”,
“offers”: {
“@type”: “Offer”,
“price”: “14.95”,
“priceCurrency”: “USD”
}
}
]
}
]
}
</script>
我意识到并非所有餐厅菜单场景都完美地涵盖了这些新的菜单属性和类型,但希望您现在至少可以开始使用。还要记住,Schema.org 词汇会不断发展,这个特定的模式领域也会不断发展。欢迎您通过Github 上的讨论参与 Schema.org 的发展。如果您认为自己有很好的建议,请随时加入讨论。
【讨论】:
Schema.org 词汇表(还没有)提供表示餐厅菜单或单个菜单项的类型。
他们的menu property 期望文本或 URL 作为值。如果应该有菜单类型,它将成为另一个预期值。
问题Extension Proposal: FoodProduct and Restaurant Menu with FoodProducts. 要求这样做。它关闭了,引用了更广泛的问题Create a new Food type (help further with foodWarning and recipeIngredient)。仍在讨论中。
如果您现在需要一些东西,您可以使用引用 OfferCatalog type(代表菜单或菜单的分组部分)的 hasOfferCatalog property 和 Offer type(代表单个菜单项,有价格)。
例如:
<div vocab="http://schema.org/" typeof="Restaurant">
<section property="hasOfferCatalog" typeof="OfferCatalog">
<h1 property="name">Menu</h1>
<ul>
<li property="itemListElement" typeof="Offer">
<b property="name">Bread</b> –
<span property="price">1.50</span>
<meta property="priceCurrency" content="EUR" />
</li>
<li property="itemListElement" typeof="Offer">
<b property="name">Water</b> –
<span property="price">1.00</span>
<meta property="priceCurrency" content="EUR" />
</li>
</ul>
</section>
</div>
如果您也想使用menu 属性,您可以添加一个包含OfferCatalog 的div。 menu 的值将是文本内容。
<div vocab="http://schema.org/" typeof="Restaurant">
<div property="menu">
<section property="hasOfferCatalog" typeof="OfferCatalog">
<!-- … -->
</section>
</div>
</div>
【讨论】:
有几个选项,取决于(某种程度上)个人喜好:
留下来看看谷歌是否理解
menu 将值定义为文本或 URL,因此提供其中任何一个就足够了。由于未遵循规范,因此执行任何其他操作可能会使 Google 或其他解析器感到困惑。
Here's an article which shows a URL providing a menu to Google without any schema,所以系统确实工作了。
在 URL 的目标位置提供架构
ItemList 是最通用的列表类型,允许您将itemListElements 添加到列表中。这并没有指定列表是菜单,但提供 URL 的菜单属性就足够了。
或者,Offer 允许您指定满足您要求的名称、描述和价格。 Product 不允许您指定价格,因此此处最好使用优惠。由于 itemListElement 可以是 Thing,因此您可以在 ItemList 中组合 Offer。
【讨论】: