Hello! I am new to AEM, and I need to figure out how to add schema structured data (in JSON-LD format) to all pages that contain one of our custom components.
I know similar questions have been asked before, but the answers weren't very detailed and a bit unclear. I'd like to know about the different approaches, and which one would be the best/most efficient.
Also it's important to note that we already have a lot of existing pages with this component, so I'm hoping for a solution that'll apply to those pages as well without having to do any re-authoring.
I would also appreciate any links to resources that may be helpful. Thanks!
Edit: One other thing I am confused about, is it incorrect to add the json-ld schema data to the component itself? This seems like it would be a straightforward solution, but no one seems to recommend it.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @IshaJa
You can this logic to page component's head section
e.g
<sly data-sly-use.scriptPojo="${'com.myproj.core.models.GenerateApplicationJson'}">
<script type="application/ld+json">
${scriptPojo.getJson @ context='styleScript'}
</script>
</sly>
Hi @IshaJa
Please check https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/schema-markup-via-json-ld/...
You can use AEM custom component, to generate JSON-LD
Hi @arunpatidar,
Thanks for responding, but my main question was how to add the JSON-LD to pages that contain a specific component. We have hundreds of pages that may contain this component, so manually adding it in through a custom component isn't an ideal option.
Hi @IshaJa
You can this logic to page component's head section
e.g
<sly data-sly-use.scriptPojo="${'com.myproj.core.models.GenerateApplicationJson'}">
<script type="application/ld+json">
${scriptPojo.getJson @ context='styleScript'}
</script>
</sly>
@IshaJa Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies