Hello Frontity team,
I’ve noticed that Google offers a better optimization for recipe related websites with including the Google Structured Data approach. See more about here: https://developers.google.com/search/docs/data-types/recipe. So, want to implement this on https://ruthgeorgiev.com.
The way Google needs this data is pretty much straightforward, simply by creating a <script>
element with the type set to application/ld+json
in the <head>
of the page. And then inside the <script>
element, have to tell Google i’ll be using schema.org structured data by setting @context
to http://schema.org
.
Also need to tell Google what kind of thing i’m describing, by adding @type
to Recipe
.
<html>
<head>
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Recipe"
}
</script>
</head>
</html>
And at the end i have to add all of the required and precommended properties into the json.
Example:
<html>
<head>
...
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Recipe",
"name": "Party Coffee Cake",
"image": "https://www.leannebrown.com/wp-content/uploads/2016/12/up-close-pear-cake.jpg",
"author": {
"@type": "Person",
"name": "Mary Stone"
},
"datePublished": "2018-03-10",
"description": "This coffee cake is awesome and perfect for parties.",
"prepTime": "PT20M",
"cookTime": "PT30M",
"totalTime": "PT50M",
"recipeYield": "10 servings",
"recipeCategory": "Dessert",
"recipeCuisine": "American",
"keywords": "cake for a party, coffee",
"nutrition": {
"@type": "NutritionInformation",
"calories": "270 calories"
},
"recipeIngredient": [
"2 cups of flour",
"3/4 cup white sugar",
"2 teaspoons baking powder",
"1/2 teaspoon salt",
"1/2 cup butter",
"2 eggs",
"3/4 cup milk"
],
"recipeInstructions": [
{
"@type": "HowToStep",
"text": "Preheat the oven to 350 degrees F. Grease and flour a 9x9 inch pan."
},
{
"@type": "HowToStep",
"text": "In a medium bowl, combine flour, sugar, and cinnamon."
},
{
"@type": "HowToStep",
"text": "Mix in butter until the entire mixture is crumbly."
},
{
"@type": "HowToStep",
"text": "In a large bowl, combine flour, sugar, baking powder, and salt."
},
{
"@type": "HowToStep",
"text": "Mix in the butter."
},
{
"@type": "HowToStep",
"text": "Spread into the prepared pan."
},
{
"@type": "HowToStep",
"text": "Sprinkle the streusel mixture on top of the cake."
},
{
"@type": "HowToStep",
"text": "Bake for 30 to 35 minutes, or until firm."
},
{
"@type": "HowToStep",
"text": "Allow to cool."
}
],
"video": [
{
"@type": "VideoObject",
"name": "How to make a Party Coffee Cake",
"description": "This is how you make a Party Coffee Cake.",
"thumbnailUrl": [
"https://example.com/photos/1x1/photo.jpg",
"https://example.com/photos/4x3/photo.jpg",
"https://example.com/photos/16x9/photo.jpg"
],
"contentUrl": "http://www.example.com/video123.flv",
"embedUrl": "http://www.example.com/videoplayer.swf?video=123",
"uploadDate": "2018-02-05T08:00:00+08:00",
"duration": "PT1M33S",
"interactionStatistic": {
"@type": "InteractionCounter",
"interactionType": { "@type": "http://schema.org/WatchAction" },
"userInteractionCount": 2347
},
"expires": "2019-02-05T08:00:00+08:00"
}
]
}
</script>
</head>
</html>
Full description here: https://codelabs.developers.google.com/codelabs/structured-data/index.html#2
Now, i already have all of this data ready in post.js
, so my question here is, is there any elegant Frontity way of how to push this data in a required format into <head>
tag?
<html>
<head>
<script type="application/ld+json">
{
/* Recipe Data */
}
</script>
</head>
</html>
Any recommendation will be greatly appreciated.
Many thanks.
All the best,
Dejan