Hello,
I have a dynamic FAQ component that pulls question–answer pairs from my database and renders them correctly on the page. Now I need to output a valid FAQPage JSON-LD schema so Google can recognize my FAQ rich result, but I think WebStudio doesn’t allow me to insert Collection tags inside a <script type="application/ld+json"> block.
What’s the best way to generate and inject the following schema dynamically (based on my rendered FAQs) without hard-coding every question and answer?
{
"@context": "
https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Where are you located?",
"acceptedAnswer": {
"@type": "Answer",
"text": "We are based in Paris, France."
}
},
{
"@type": "Question",
"name": "Do you offer private sailing lessons?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes, private lessons are available on request."
}
}
/* …and so on for each FAQ item… */
]
}
Has anyone implemented a solution (JavaScript embed or WebStudio workaround) that reads the rendered FAQ items and automatically generates this <script type="application/ld+json"> block? Any code snippets or step-by-step guidance would be greatly appreciated.