Hi everyone,
I'm trying to add a rich snippet schema directly in the header for Google, but I'm running into an issue. My script needs to be populated with backend data, but when I pass the data, it ends up being empty.
Any suggestions on how to resolve this?
Solved! Go to Solution.
Views
Replies
Total Likes
Try giving a suitable context to the properties https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#121-display-context
Something like
<template data-sly-template.richschema="${ @ objectWithProperties }">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SearchResultsPage",
"name": "${objectWithProperties.title @ context='scriptString'}",
"description": "${objectWithProperties.description @ context='scriptString'}",
"url": "${objectWithProperties.url @ context='scriptString'}"
}
</script>
</template>
jsonString is also supported since htl-engine-1422-140, so you can try that as well, if it works it will be more suitable
https://sling.apache.org/documentation/bundles/scripting/scripting-htl.html#display-context-supporte...
Try giving a suitable context to the properties https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#121-display-context
Something like
<template data-sly-template.richschema="${ @ objectWithProperties }">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SearchResultsPage",
"name": "${objectWithProperties.title @ context='scriptString'}",
"description": "${objectWithProperties.description @ context='scriptString'}",
"url": "${objectWithProperties.url @ context='scriptString'}"
}
</script>
</template>
jsonString is also supported since htl-engine-1422-140, so you can try that as well, if it works it will be more suitable
https://sling.apache.org/documentation/bundles/scripting/scripting-htl.html#display-context-supporte...
Views
Likes
Replies
Views
Likes
Replies