1
votes

How do I nest one or multiple recipes in a NewsArticle or BlogPosting.

I tried this but Google's Structured Data Testing Tool throws an error complaining about recipe1 key. I'm not sure what to change recipe1 key to:

  <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>
2
What do you want to convey? What would be the purpose of BlogPosting inside a NewsArticle? For quoting? And what would be the purpose of Recipe inside NewsArticle? Is it the main content of the article? But in that case, is it really a NewsArticle? - unor
Let's say I want a Recipe (or more) inside a BlogPosting. - Gezim

2 Answers

1
votes

It depends on how the entities are related to each other. You have to use a property that is defined to convey this relation.

To look for a suitable property, check BlogPosting for properties that have Recipe or one of its parent types (CreativeWork, Thing) as expected value.

For example:

  • about could be used if the blog post is about this specific recipe (e.g., you describe how you liked it)
  • hasPart could be used if the recipe forms a part of the blog post
  • mentions could be used if you just reference this recipe in the blog post
  • …
0
votes

Thanks @unor. I've used hasPart as follows:

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

It validates as validates JSON-LD.