Enable DISQUS only for selected type of posts

Hi all!

I am trying to design an academic homepage with blog. So naturally I don’t want all posts to have DISQUS comment options. I would like to enable DISQUS only for specific type or posts from a specific folder say “post”. Is that possible?

Yes, this is possible. You can have different layouts for different sections of content in Hugo. Just create a layout just for posts with Disqus.

Relevant docs: https://gohugo.io/templates/content/
Example of sections: https://github.com/hnarayanan/harishnarayanan.org/tree/master/layout

You could also wrap the disqus code with an if statement. Depending on your setup you’ve to adapt it.

{{ if ne .Type "YOUR_TYPE" }}
// your disqus code
{{ end }}
1 Like

Thanks a lot guys! I will try this soon. Will bother you again if I need any help.