Skip to content

Automated Structured Data

Structured data (also called “schema markup” or “JSON-LD”) helps search engines understand your content better. It can also make your pages eligible for rich results in Google — special search listings that show extra information like star ratings, images, or in this case, comment counts.

JamComments can automatically add structured data for your comments, even merging it with your existing “BlogPost” or “Article” schema.

JamComments offers two approaches, balancing ease of use with maximum compatibility:

By default, JamComments generates structured data using JavaScript in the browser. This approach:

  • Works with every integration without any configuration
  • Automatically finds any existing “BlogPosting” or “Article” schema on your page and merges comment data into it
  • Is fully supported by Google

This is the easiest option — it just works.

If you want the structured data to be in your HTML from the start (helpful for search engines that don’t run JavaScript), you can enable server-side rendering.

Note: This is currently only supported in the Astro integration, but coming to others soon.

To use it, pass your page’s schema to the <JamComments> component instead of rendering it yourself:

---
const postSchema = {
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "My Blog Post",
"datePublished": "2024-04-03"
};
---
<JamComments schema={postSchema} />

JamComments will merge your comment data into the schema and render the complete JSON-LD in your HTML.

For more details on this approach, see the Astro integration docs.

Either way, here’s an example of what gets generated:

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "My Blog Post",
"datePublished": "2024-04-03T20:44:05.000-05:00",
"comment": [
{
"@context": "https://schema.org",
"@type": "Comment",
"dateCreated": "2024-05-12T06:25:37+00:00",
"text": "Great article!",
"author": {
"@type": "Person",
"name": "Jane Doe"
}
}
]
}
</script>

It’s a good idea to validate that your structured data is working correctly: