Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable Disqus comments #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

How to enable Disqus comments #4

wants to merge 1 commit into from

Conversation

yihui
Copy link
Owner

@yihui yihui commented Jun 20, 2017

Add {{ template "_internal/disqus.html" . }} to foot_custom.html, and configure the Disqus shortname in config.toml.

Preview: https://deploy-preview-4--hugo-xmin.netlify.com/

@yihui yihui added the feature label Jun 22, 2017
@yihui yihui force-pushed the feature/disqus branch 2 times, most recently from 295102e to 8452188 Compare July 3, 2017 18:18
@yihui yihui force-pushed the feature/disqus branch 3 times, most recently from daff20e to bb60546 Compare July 13, 2017 07:08
@histrio
Copy link

histrio commented Aug 14, 2017

This will lead to comments block appearing on the main page also.

@yihui
Copy link
Owner Author

yihui commented Aug 14, 2017

Yes, and you can load comments conditionally, e.g. https://github.com/yihui/hugo-lithium-theme/blob/master/layouts/partials/disqus.html#L1 Use a parameter disable_comments: false in the YAML metadata of a post to disable comments for a specific post.

@histrio
Copy link

histrio commented Aug 15, 2017

Thanks, yihui
How can I disable comments on the main page (list.html) then?

@yihui
Copy link
Owner Author

yihui commented Aug 15, 2017

@histrio Please see https://gohugo.io/variables/page/ for more available variables that you can use.

@oneleaftea
Copy link
Contributor

@histrio easiest way is to simply add it to the single.html template above the footer instead of the footer template itself. Then it won't show up on the main page or list pages.

@histrio
Copy link

histrio commented Aug 25, 2017

@oneleaftea I resolve it like this

{{ if .IsPage }}
  {{ template "_internal/disqus.html" . }}
{{ end }}

in layouts/partials/foot_custom.html

@Hussain-Alsalman
Copy link

You could create /post sub folder in layout folder and create custom single.html. This will also prevent comments section to appear on other pages except posts.

@anest-uk
Copy link

I have most of this working on both xmin and learn patterns as described above:
@oneleaftea "I resolve it like this"

So I am making only one change (outside of config.toml) to foot_custom.html.

However adding disable_comments: false or disable_comments: true to the front matter of a page makes no difference - I always get disqus enabled i.e. it shows up at the foot when deployed to netlify.

I'd like to suppress comments on some pages.

@pat-alt
Copy link

pat-alt commented Feb 7, 2021

@oneleaftea I resolve it like this

{{ if .IsPage }}
  {{ template "_internal/disqus.html" . }}
{{ end }}

in layouts/partials/foot_custom.html

To make sure comments are only enabled under posts, @oneleaftea's suggestion can be tweaked slightly:

{{ if eq .Section "post" }}
  {{ template "_internal/disqus.html" . }}
{{ end }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants