Trying to reference another CMS collection in the before body tag of a CMS collection

Hi all,

I’ve built a Webflow site that has programmatic SEO with Google schema markup included. As part of this I have a dynamic CMS template (Categories), and each of them has its own FAQ which is its own collection with Category as a reference.

I’m trying to add FAQ schema markup to the Categories CMS page, but I need to be able to reference the specific FAQ question and answer within the Categories CMS page, which it doesn’t let me do. It only shows me the fields in Categories CMS, not the reference fields. My FAQ has a reference to Categories, and my Categories has a multi-reference to FAQ.

This is the example snippet I want to use and in [brackets] are the dynamic FAQ values I want to add.

Any idea how to make this work?

To add FAQ schema markup to your Categories CMS page, you need to use Webflow’s dynamic data and reference fields. Here’s how you can achieve this:

  1. On your Categories CMS template, create a new dynamic field to hold the FAQ schema markup. You can call this field “FAQ Schema.”
  2. In the “FAQ Schema” field, you can use Webflow’s custom code component to add the following code snippet:
  1. Replace the [FAQ Question Field Value] and [FAQ Answer Field Value] placeholders in the code with dynamic data from your FAQ collection. You can access the values of the reference fields in the custom code component using Webflow’s dynamic data syntax. For example:

In the example above, “reference_field_name” should be replaced with the name of the reference field from your FAQ collection that refers to the Categories collection. “faq_question_field_name” and “faq_answer_field_name” should be replaced with the names of the fields in your FAQ collection that hold the FAQ question and answer, respectively.

This should allow you to dynamically reference the specific FAQ question and answer within your Categories CMS page and include them in your FAQ schema markup.
You can Thanks me here: My Site

Thank you, I think you may have forgotten to paste the code snippet? Also not sure I understand the first step, is it in the CMS settings of the categories page I need to add the dynamic field? Which one do I choose that can hold the code, text?

For anyone seeing this in future… I figured it out based on this template and this post.

The way to do it is using custom attributes.