How to disable comments in specific pages?

Hi, all.

I have comments enalbed (gitalk to be exactly). It works perfect byt I want to disable comments in specific pages( for instance, Terms of Use and Privacy Service pages).

My first attempt was to make a copy of

themes/zzo/layouts/_default/single.html

to

layouts/_default/single.html

and edit it to remove comments snippet. The problem is that it removed comments from all pages.

Could someone point me how to do it?

Thank you.

Notes:

I’m using

  • Hugo version 0.60.1
  • Zzo theme (updated yesterday)

You still need to decide how a page knows if comments should show. Adding an option to a page’s frontmatter works for that.

1 Like

In your layout (https://github.com/zzossig/hugo-theme-zzo/blob/2e0f52a48f7aaa31f19b09a65e020744531fba3d/layouts/partials/comments/comments.html), something like:

    {{ if not .Params.noComment }}
        Comment
    {{ end }}

In your frontmatter (yaml):

noComment: true
4 Likes

Sorry guys for taking so long to reply.

@nfriedli Your answer solved my problem. Thanks.

And thank you @maiki for pointing me the docs.