2016-09-25 106 views
1

如何在NewsArticleBlogPosting中嵌套一個或多個配方。schema.org中的多個實體

我試過這個,但Google's Structured Data Testing Tool拋出一個錯誤,抱怨recipe1鍵。我不知道是什麼改變recipe1關鍵:

<script type="application/ld+json"> 
{ 
"@context" : "http://schema.org", 
    "@type" : "NewsArticle", 
    "author" : { "@type" : "Person", 
     "name" : "hgezim" 
    }, 
    "dateModified" : "2016-09-21T06:25:35+00:00", 
    "datePublished" : "2016-09-21T06:25:35+00:00", 
    "headline" : "Chicken Papriak", 
    "mainEntityOfPage" : "http://localhost:8080/2016/09/21/chicken-papriak/", 
    "publisher" : { "@type" : "Organization", 
     "name" : "Dev Blog" 
    }, 
    "recipe1": { 
    "@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> 
+0

你想表達什麼? 'NewsArticle'內的'BlogPosting'的目的是什麼?報價? 「NewsArticle」內部的「食譜」的目的是什麼?這是文章的主要內容嗎?但是在那種情況下,它真的是一個「新聞文章」嗎? – unor

+0

假設我想要一個'BlogPosting'裏的'Recipe'(或更多)。 – Gezim

回答

1

這取決於實體如何彼此相關。您必須使用定義的屬性來傳達此關係。

爲了尋找合適的屬性,檢查BlogPosting對於具有Recipe或其父類型之一(CreativeWorkThing)性能期望值。

例如:

  • about如果博客文章是關於這個特定的配方可使用(例如,你描述你怎麼喜歡它)如果配方形成的一部分
  • hasPart可以使用博客文章,如果你只是參考這個食譜的博客文章
  • mentions可以用來...
0

謝謝@unor。我用hasPart如下:

<script type="application/ld+json"> 
{ "@context" : "http://schema.org", 
    "@type" : "NewsArticle", 
    "author" : { "@type" : "Person", 
     "name" : "hgezim" 
    }, 
    "dateModified" : "2016-09-21T06:25:35+00:00", 
    "datePublished" : "2016-09-21T06:25:35+00:00", 
    "hasPart" : { "@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", 
     "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", 
     "recipeIngredient" : [ "3 or 4 ripe bananas, smashed", 
      "1 egg", 
      "3/4 cup of sugar" 
     ], 
     "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" 
    }, 
    "headline" : "Chicken Papriak", 
    "mainEntityOfPage" : "http://localhost:8080/2016/09/21/chicken-papriak/", 
    "publisher" : { "@type" : "Organization", 
     "name" : "Dev Blog" 
    } 
} 
</script> 

它驗證爲validates JSON-LD