问题原文
原帖链接 · Christopher Karam · CC BY-SA 4.0
I make articles on specific ingredients and provide their nutrition facts.
On my article page, I have this current schema for the Article type which works perfectly fine from what I know. But I'd like to have another schema that includes the nutrition label on the webpage.
If I can add another schema to the code:
- Can it be in the same
scripttag? - Which one should be used?
<!-- JSON-LD markup generated by Google Structured Data Markup Helper. -->
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "http://cathscafe.example.com/"
},
"name" : "Olive Oil Review - 2019",
"headline" : "Olive Oil Review",
"author" : {
"@type" : "Person",
"name" : "Christopher Karam"
},
"datePublished" : "2019-01-04",
"dateModified" : "2019-01-04",
"image" : "https://static1.squarespace.com/static/59a7820e2994ca11766093d3/t/5b00a06f575d1f8e6e07c981/1526767728080/olive-oil-fat-healthy-food-dietary-my-diet-goal-small-hd.jpg",
"articleSection" : "Wellness",
"articleBody" : "Olive oil is a liquid fat obtained from olives, a traditional tree crop of the Mediterranean. The oil is produced by cold pressing whole olives...",
"url" : "https://mydietgoal.com/olive-oil",
"publisher" : {
"@type" : "Organization",
"name" : "MyDietGoal",
"logo" : {
"@type": "ImageObject",
"name": "MyDietGoalLogo",
"url" : "https://static1.squarespace.com/static/59a7820e2994ca11766093d3/t/5b6f96c6032be42d1403dd79/1551652043684.jpg",
"width" : "250",
"height" : "250"
}},
"aggregateRating" : {
"@type" : "AggregateRating",
"ratingValue" : "5.0",
"bestRating" : "5.0",
"ratingCount" : "6"
}
}
</script>
已采纳解答
原帖链接 · Kuba Serafinowski · CC BY-SA 4.0
According to schema.org NutritionInformation is only applicable to menu items or recipes. If you are trying to markup something else you would need to emulate this with all of the required fields.
Putting another object in the same <script> tag would technically be correct, you need to use a JSON array[], though.
Neither Google's validator nor Yandex' validator will return any warnings or errors for such a snippet:
<script type="application/ld+json">
[
{
"@context" : "http://schema.org",
"@type" : "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "http://cathscafe.example.com/"
},
"name" : "Olive Oil Review - 2019",
"headline" : "Olive Oil Review",
"author" : {
"@type" : "Person",
"name" : "Christopher Karam"
},
"datePublished" : "2019-01-04",
"dateModified" : "2019-01-04",
"image" : "https://static1.squarespace.com/static/59a7820e2994ca11766093d3/t/5b00a06f575d1f8e6e07c981/1526767728080/olive-oil-fat-healthy-food-dietary-my-diet-goal-small-hd.jpg",
"articleSection" : "Wellness",
"articleBody" : "Olive oil is a liquid fat obtained from olives, a traditional tree crop of the Mediterranean. The oil is produced by cold pressing whole olives...",
"url" : "https://mydietgoal.com/olive-oil",
"publisher" : {
"@type" : "Organization",
"name" : "MyDietGoal",
"logo" : {
"@type": "ImageObject",
"name": "MyDietGoalLogo",
"url" : "https://static1.squarespace.com/static/59a7820e2994ca11766093d3/t/5b6f96c6032be42d1403dd79/1551652043684.jpg",
"width" : "250",
"height" : "250"
}},
"aggregateRating" : {
"@type" : "AggregateRating",
"ratingValue" : "5.0",
"bestRating" : "5.0",
"ratingCount" : "6"
}
},
{
"@context": "http://schema.org",
"@type": "Recipe",
"author": "John Smith",
"cookTime": "PT1H",
"datePublished": "2009-05-08",
"description": "This classic banana bread recipe comes from my mom -- the walnuts add a nice texture and flavor to the banana bread.",
"image": "bananabread.jpg",
"recipeIngredient": [
"3 or 4 ripe bananas, smashed",
"1 egg",
"3/4 cup of sugar"
],
"interactionStatistic": {
"@type": "InteractionCounter",
"interactionType": "http://schema.org/Comment",
"userInteractionCount": "140"
},
"name": "Mom's World Famous Banana Bread",
"nutrition": {
"@type": "NutritionInformation",
"calories": "240 calories",
"fatContent": "9 grams fat"
},
"prepTime": "PT15M",
"recipeInstructions": "Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add the flour last. Pour the mixture into a loaf pan and bake for one hour.",
"recipeYield": "1 loaf",
"suitableForDiet": "http://schema.org/LowFatDiet"
}
]
</script>
If you wish you can put both of them in separate <script> tags, and the result will be the same:
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "http://cathscafe.example.com/"
},
"name" : "Olive Oil Review - 2019",
"headline" : "Olive Oil Review",
"author" : {
"@type" : "Person",
"name" : "Christopher Karam"
},
"datePublished" : "2019-01-04",
"dateModified" : "2019-01-04",
"image" : "https://static1.squarespace.com/static/59a7820e2994ca11766093d3/t/5b00a06f575d1f8e6e07c981/1526767728080/olive-oil-fat-healthy-food-dietary-my-diet-goal-small-hd.jpg",
"articleSection" : "Wellness",
"articleBody" : "Olive oil is a liquid fat obtained from olives, a traditional tree crop of the Mediterranean. The oil is produced by cold pressing whole olives...",
"url" : "https://mydietgoal.com/olive-oil",
"publisher" : {
"@type" : "Organization",
"name" : "MyDietGoal",
"logo" : {
"@type": "ImageObject",
"name": "MyDietGoalLogo",
"url" : "https://static1.squarespace.com/static/59a7820e2994ca11766093d3/t/5b6f96c6032be42d1403dd79/1551652043684.jpg",
"width" : "250",
"height" : "250"
}},
"aggregateRating" : {
"@type" : "AggregateRating",
"ratingValue" : "5.0",
"bestRating" : "5.0",
"ratingCount" : "6"
}
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Recipe",
"author": "John Smith",
"cookTime": "PT1H",
"datePublished": "2009-05-08",
"description": "This classic banana bread recipe comes from my mom -- the walnuts add a nice texture and flavor to the banana bread.",
"image": "bananabread.jpg",
"recipeIngredient": [
"3 or 4 ripe bananas, smashed",
"1 egg",
"3/4 cup of sugar"
],
"interactionStatistic": {
"@type": "InteractionCounter",
"interactionType": "http://schema.org/Comment",
"userInteractionCount": "140"
},
"name": "Mom's World Famous Banana Bread",
"nutrition": {
"@type": "NutritionInformation",
"calories": "240 calories",
"fatContent": "9 grams fat"
},
"prepTime": "PT15M",
"recipeInstructions": "Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add the flour last. Pour the mixture into a loaf pan and bake for one hour.",
"recipeYield": "1 loaf",
"suitableForDiet": "http://schema.org/LowFatDiet"
}
</script>
You can find more on this here.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
