I've started creating a new model and controller to generate FAQ schema data for each FAQ item on a given page.
I'd like to render this in a Schema data partial in the format below, however the part i'm struggling with is how to generate a question & answer set in JSON for each nested content item/FAQ.
Razor is not for structured data markup, Razor is for rendering HTML. Razor is very bad in rendering JSON, javascript, or structured data.
That's why I don't recommend you to render the structured data with Razor, I think there are 2 little bit better ways of rendering the Structured data:
1) use Schema.NET library - https://www.nuget.org/packages/Schema.NET - Schema.org objects turned into strongly typed C# POCO classes for use in .NET. All classes can be serialized into JSON/JSON-LD and XML, typically used to represent structured data in the head section of the HTML page.
And of course, these 2 options are not optimal for things like breadcrumb - in this case, probably makes sense to use Microdata format instead of ld+json
Please, share how did you go with it and your thoughts.
I marked your answer as the solution to this, having looked at the link for the Schema.Net package it looks perfect what we were trying to do so I believe it is the approach we want to take.
I just wanted to tag a note on this post though to say that having tried to install the Schema.Net package through package manager in Visual Studio, it actually ripped out Umbraco 7.10.5 from my local dev environment and after the Schema.Net package installed, it then proceeded to try and install Umbraco 7.15
Didn't see anything on the Schema.Net git page which pre-warned about this unless I've missed it so wanted to flag it on this post, just in case.
Alex, David thanks a lot for your comments and pointing me in the right direction.
I'll give those a look over and drop a note back on here with the final solution just in case anybody else is looking for it. Creating structured data for our standard product pages seems simple enough as there's only one block of JSON per page, it's generating the data for those nested content FAQ's that I couldn't get my head around :)
Generate Schema Markup for Nested Content
Hi there,
I've started creating a new model and controller to generate FAQ schema data for each FAQ item on a given page.
I'd like to render this in a Schema data partial in the format below, however the part i'm struggling with is how to generate a question & answer set in JSON for each nested content item/FAQ.
Anybody done this before? or any pointers, packages or reference sites I could take a look at?
Cheers Stuart
Hi Stuart,
Razor is not for structured data markup, Razor is for rendering HTML. Razor is very bad in rendering JSON, javascript, or structured data.
That's why I don't recommend you to render the structured data with Razor, I think there are 2 little bit better ways of rendering the Structured data:
1) use Schema.NET library - https://www.nuget.org/packages/Schema.NET - Schema.org objects turned into strongly typed C# POCO classes for use in .NET. All classes can be serialized into JSON/JSON-LD and XML, typically used to represent structured data in the head section of the HTML page.
2) use Structured Data Markup Helper to render Structured data and then store rendered data in the CMS in the text field - https://www.google.com/webmasters/markup-helper/u/0/
And of course, these 2 options are not optimal for things like breadcrumb - in this case, probably makes sense to use Microdata format instead of ld+json
Please, share how did you go with it and your thoughts.
Thanks,
Alex
Hi Alex,
I marked your answer as the solution to this, having looked at the link for the Schema.Net package it looks perfect what we were trying to do so I believe it is the approach we want to take.
I just wanted to tag a note on this post though to say that having tried to install the Schema.Net package through package manager in Visual Studio, it actually ripped out Umbraco 7.10.5 from my local dev environment and after the Schema.Net package installed, it then proceeded to try and install Umbraco 7.15
Didn't see anything on the Schema.Net git page which pre-warned about this unless I've missed it so wanted to flag it on this post, just in case.
Cheers Stuart
Hi Stuart
Thanks for letting us know about this problem. Maybe you have to use -IgnoreDependencies? But I'm not sure why nuget do it like that.
Thanks,
Alex
I used MXTires.Microdata very successfully, but there's not harm in just using a JObject in my book.
Alex, David thanks a lot for your comments and pointing me in the right direction.
I'll give those a look over and drop a note back on here with the final solution just in case anybody else is looking for it. Creating structured data for our standard product pages seems simple enough as there's only one block of JSON per page, it's generating the data for those nested content FAQ's that I couldn't get my head around :)
Cheers, Stuart
is working on a reply...