But I need to make the whole thing dynamic and render correctly (< instead of <).
I read somewhere that this isn’t possible, but that’s why I’m looking for an “out of the box” solution.
I’m using schema JSON markup on a CMS collection. Some pages have a video, others don’t. I need to apply schema accordingly and there’s no way to do this by simply inserting a field into a header/footer tag. If I could filter, I would. Not possible.
Any information you can provide would be very much appreciated.
Hi there, not sure what you mean by that. Is all you need the following? You can add things like this into the Custom Code section of the CMS Template page settings.
Thanks @spirelli. Yes, I am aware of this technique. I did my best to explain that in paragraph three but may have fallen short.
To answer your question, imagine I’m trying to make the whole code (highlighted in your example) dynamic. In my original post, I’m trying to add specific schema JSON to some and not others. I can’t just slot in the field between the quotation marks. I need to have specific tags on one page and not another.
<script>
if (!$("#youtube-video-1").hasClass("w-condition-invisible")) { // If YouTube video has been added, include the following Schema ('!' from this line reverses logic)
var schema = {
"@context":"https://schema.org",
"@graph": [
{
"@type": "VideoObject",
"name": "The Cross at the Center (Part 2)",
"description": "The cross distinguishes Christianity from all other religions. It is the source of all grace, the basis of Satan's defeat, the door to God's secret wisdom, the ultimate demonstration of God's love.",
"thumbnailUrl": [
"https://img.youtube.com/vi/uys0luOM87U/mqdefault.jpg",
"https://img.youtube.com/vi/uys0luOM87U/0.jpg",
"https://img.youtube.com/vi/uys0luOM87U/maxresdefault.jpg"
],
"author": {
"@type": "Person",
"name": "Derek Prince"
},
"publisher": {
"@type": "Organization",
"name": "Derek Prince Ministries",
"logo": {
"@type": "ImageObject",
"name": "Derek Prince Ministries",
"url": "https://global-uploads.webflow.com/5f6175a45ad601c93a7b2a10/6010983d98361736dddd5b8c_logo_derek_prince_international_01_blue.svg",
"width": 1200,
"height": 257
}
},
"uploadDate": "2015-04-17",
"contentUrl": "https://www.youtube.com/watch?v=uys0luOM87U",
"embedUrl": "https://www.youtube.com/embed/uys0luOM87U"
}
]
}
var script = document.createElement('script');
script.type = "application/ld+json";
script.text = JSON.stringify(schema);
document.querySelector('body').appendChild(script);
}
</script>