Quick-search for anything
⌘F

comments

Usage: {{comments}}

Description

The {{comments}} helper outputs Ghost’s member-based commenting system. Learn more about comments.

Comments are visible only when they have been (1) enabled by the publication owner and (2) the person visiting the page has access to the post.

Basic example

{{comments}}

By default, {{comments}} outputs a title and comment count. These elements, along with the color mode and the saturation of the avatar's background color, can be customized via attributes.

Attributes

NameDescriptionOptionsDefault
titleHeader text for comment sectionAny stringMember discussion
countBoolean to toggle comment count on or offtrue or falsetrue
modeSet light or dark mode for commentsauto, light, or darkauto (determined by the parent element's CSS color property)
saturationSet saturation of avatar background colornumber60

Example with attributes

{{comments title="Join the club" count=false mode="light" saturation=80}}
{{! Customizes header text, hides comment count, sets element to light mode and avatar background color saturation to 80% }}

Comment count

Use {{comment_count}} to output the number of comments a post has. This option is useful for displaying the comment count on the homepage or at the top of the post. Developers can also use it to customize the output of the {{comments}} helper.

Attributes

NameDescriptionOptionsDefault
singularThe singular name for a commentAny stringcomment
pluralThe plural name for commentsAny stringcomments
emptyWhat to output when there are no commentsAny stringOutput is empty when comment count equals zero
autowrapWraps comment count in an HTML tagHTML tag or falsespan
classAdd a custom class to wrapper elementAny string""

Examples

{{comment_count empty="" singular="comment" plural="comments" autowrap="span" class=""}}
{{! default output: <span>5 comments</span> }}

{{comment_count singular="" plural=""}}
{{! output: <span>5</span> }}

{{comment_count empty="0"}}
{{! output: <span>0</span>. (The default is an empty output.) }}

{{comment_count autowrap="div" class="style-me"}}
{{! output: <div class="style-me">5 comments</span> }}

{{comment_count autowrap="false"}}
{{! output: 5 comments (just text!) }}

Additional customization

Use the comments helper with {{#if}} for more granular control over output. {{#if comments}} returns true when (1) comments have been enabled and (2) the reader has access to the post.

Advanced example

{{#if comments}}
   <h2>Discussion</h2>
   <a href="/guides">Community guidelines</a>
   {{comment_count}}
   {{comments title="" count=false mode="light" saturation=80}}
{{/if}}