Schema
Comment Schema
On this page
Schema.org Comment
- Type:
defineComment<T extends Record<string, any>>(input?: Comment & T)
Describes a comment, usually in the context of an Article or WebPage.
Useful Links
Required properties
- text
string
Content of the comment. - author
Person | Organization
Unhead moves the registered author to a root Schema node. The field resolves to an@idreference to a Person or an Organization. An author without@typeresolves as a Person.
Defaults
- @type:
Comment - @id:
${canonicalUrl}#/schema/comment/{n} - about: Article reference
Resolves
authoris resolved as a root Person or Organization node and replaced with an ID referencedateCreated,dateModified, anddatePublishedaccept Date objects and are serialized as ISO 8601 strings
Examples
See the blog recipe for more examples.
Minimal
defineComment({
text: 'The setup guide answered my question.',
author: {
name: 'Harlan Wilton',
url: 'https://harlanzw.com',
}
})
Types
export interface CommentSimple extends Thing {
/**
* The textual content of the comment, stripping HTML tags.
*/
text: string
/**
* A reference by ID to the parent Article (or WebPage, when no Article is present).
*/
about?: IdReference
/**
* A reference by ID to the Person who wrote the comment.
*/
author: NodeRelation<Identity>
/**
* The date and time the comment was created.
*/
dateCreated?: ResolvableDate
/**
* The date and time the comment was last modified.
*/
dateModified?: ResolvableDate
/**
* The date and time the comment was published.
*/
datePublished?: ResolvableDate
/**
* Replies to this comment.
*/
comment?: NodeRelations<Comment>
/**
* The number of replies.
*/
commentCount?: number
/**
* The source type when content was generated or edited algorithmically.
*/
digitalSourceType?: DigitalSourceType
/**
* Images attached to the comment.
*/
image?: NodeRelations<ImageObject | string>
/**
* Videos attached to the comment.
*/
video?: NodeRelations<VideoObject | string>
/**
* The number of upvotes the comment has received.
*/
upvoteCount?: number
/**
* The number of downvotes the comment has received.
*/
downvoteCount?: number
}
Related Schemas
Did this page help you?
Breadcrumb Schema: BreadcrumbList JSON-LD Example
Add breadcrumb schema with defineBreadcrumb(). See the BreadcrumbList JSON-LD that Unhead renders, the required itemListElement, and positions.
Course Schema
Use defineCourse() to add Course structured data with a provider, description, and course details.