JSON schema from CMS

I store schema.org schemas in a CMS field and add them to the page with

<script type="application/ld+json">
(CMS field here)
</script>

Besides the fact that this field is inside the script tags, Webflow converts all commas characters to &quot;.

How can I avoid this? Thank you in advance.

1 Like

Either decode the encoded content or use a rich text field to place an embed which contains your schema data. Webflow does not encode that.

1 Like

Thank you for so quick reply! Can I decode the content right inside this block?
<script type="application/ld+json">
…
</script>

You can with code but the latter method I suggested is much easier.

1 Like

:+1:
Thank you so much!

Perhaps I didn’t understand something, but the rich text field can’t be added to the custom code.

Rich text fields can have custom code embedded in them (<> symbol). See the University. You basically are using it as a container to hold code since Webflow will not encode the contents. It is a workaround that works.

Thank you. I understand it can contain a code, but I don’t understand, how can I add this rich text field to the page template custom code with the +Add Field. This function doesn’t show rich-text fields. Or I shouldn’t add it there, and I can add a hidden rich-text element with this field somewhere in the body with the page designer?

Yes this is the approach. You need to put your JSON in the RTF custom code. Then render the RTF on the page as a RTF element.

It worked! Thank you so much!

Hi you two, question:

  1. I see ability to add a “code” block to the RTF, but do not see a way to then also have the RTF CMS entity populate within the RTF field.

How are you both selecting “code block” and having the RTF field read data from the CMS?

Could you add a gif or some screen shots?

Hey guys,

I am trying to the same thing with schema.org customisation in collection settings. When I want to tie schema.org description with my custom rich text field Description by clicking +Add Field, it won’t display my rich text field in the dropdown of the the +AddField. Any work around for this, or maybe provide an answer with some steps I need to follow/do/implement?

Thanks ever so much!

Hi @webdev @Chekanov , I cannot follow you both on this one:

  1. I create a RTF in my CMS and add the schema.org code for each item in the cms.

Then I tried:
I create a Rich Text Block and add text from cms? → this will not lead to correct display of schema.org code

Then created Rich Text Block and add custom code in there. But the Custom code editor will not let me select CMS field from here.

It would be so great if one of you could give a quick hint, as I am really struggeling here.

Thanks so much.

Your schema code would need to be added to the document head where CMS values can be inserted into a code block.