The community member is working on a blog project using Payload CMS and Webstudio. They have set up a GraphQL API on Payload to retrieve blog post data and are able to successfully retrieve the data in Webstudio. Their goal is to dynamically generate JSON-LD code for each post's structured data within Webstudio, and they are unsure how to create a JSON-LD template that can use variables based on the API response and adapt to each post's data. The community member has also implemented structured data using microdata, but would like to generate JSON-LD for optimal implementation as recommended by Google.
In the comments, a community member provides a sample script tag with JSON-LD code that uses variables from the API response to populate the structured data fields. The community member suggests pasting this into the expression editor in an HTML embed.
I'm currently working on a blog project using Payload CMS and Webstudio. I've set up a GraphQL API on Payload to retrieve my blog post data (title, description, author, image, etc.). I'm able to successfully retrieve the data in Webstudio via an API request.
My goal is to dynamically generate JSON-LD code for each post's structured data, directly within Webstudio. I'm not sure how to create a JSON-LD template in Webstudio that can use variables based on the API response and that would change based on the post's slug (URL parameter). How can I make the JSON-LD code automatically adapt to each post's data?
I've also implemented structured data using microdata with itemscope, itemtype, and itemprop attributes directly in my HTML. However, I'd also like to generate JSON-LD for optimal implementation, as recommended by Google.
`here's what I have on webstudio's site.","upvoteCount":0,"dateCreated":"2024-12-30T12:56:18.319Z","datePublished":"2024-12-30T12:56:18.319Z","dateModified":"2024-12-30T12:56:18.319Z","url":"https://help.webstudio.is/dynamic-jsonld-generation-2gPdfmFqJj4s#4f0ba0c6-459c-4e6b-a0e8-cba2a231a960","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},"suggestedAnswer":[{"@type":"Answer","text":"And paste this into the expression editor in an html embed","upvoteCount":0,"dateCreated":"2024-12-30T12:58:53.137Z","datePublished":"2024-12-30T12:58:53.137Z","dateModified":"2024-12-30T12:58:53.137Z","url":"https://help.webstudio.is/dynamic-jsonld-generation-2gPdfmFqJj4s#91ce5f9a-7a98-4f28-9f2c-f4afaea74675","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},{"@type":"Answer","text":"Love y so much π","upvoteCount":0,"dateCreated":"2024-12-31T10:06:53.695Z","datePublished":"2024-12-31T10:06:53.695Z","dateModified":"2024-12-31T10:06:53.695Z","url":"https://help.webstudio.is/dynamic-jsonld-generation-2gPdfmFqJj4s#e97f7054-8c65-4ba0-8aa9-27c27c058546","author":{"@type":"Person","url":"https://help.webstudio.is/members/f623c301-541b-4951-9689-b1996b117cf7","name":"Mr Bean","identifier":"f623c301-541b-4951-9689-b1996b117cf7","image":"https://cdn.discordapp.com/avatars/219368881800609792/f3cbc6fa051e291e562b4da9154bddaf.webp?size=256"}}]}}