Store the entire schema as static text inside of a rich text CMS field inside of an HTML embed node. You get 100% control, and 100% variation between CMS items but it’s all static. Also not ideal if clients are editing this.
Store the content you want in the schema in plaintext fields, so that you can use a page-level HTML embed and selectively insert those fields into the schema. More automated, but may involve content duplication. For Q&A schema this is often easier though.
Build a script solution to compose the schema for you. This automates it but involves coding. In some cases, Google might not run & index these reliably. But it seems pretty reliable if the script is inline.
Store the content you want in the schema in plaintext fields, so that you can use a page-level HTML embed and selectively insert those fields into the schema. More automated, but may involve content duplication. For Q&A schema this is often easier though.
Do you know how can I turn HTML elements from plaintext fields to display correctly (i.e. ordered and unordered lists) on the page? I guess I need to add some piece of code here
If you really want list in you schema content I’d probably stick with HTML, which means option 1 or 3. Check Google specs on the schema you’re using, it ignores a lot of large HTML text fields in schemas.
I don’t think option 2 would work here because even if you manually format your plain text lists, it will likely be interpreted as a single line of text.
I’m not sure I understand the 1st option. If I store entire schema as static text inside of a rich text CMS field, I won’t be able to add it to the page body.
Rich text fields support an HTML Embed subfield. It’s on the same menu as inserting images, video, etc in your rich text content. You can store your schema inside of that HTML Embed sub-element.
To add it to your page, you just drop a rich text element and bind it to that rich text CMS field. That part of the content is delivered unedited, in raw form.
At it stands, it only works with plain text - however it can be adapted to work with rich text too. It would be a bit harder since rich text is actually a collection of HTML elements instead of just one.
In my experience, the text field is always plaintext, not Rich Text/HTML… In this instance, I’d have the Ordered List in plain text just as 1) Item 1, 2) Item 2, ... I don’t think that having HTML in the text field in JSON-LD Schema.org is technically correct. But if you run it through https://validator.schema.org/ Snippet checker and it comes back good, then it’s good.