pugillum / pugillum.github.io

0 stars 0 forks source link

posts/2021_11_28_github_issues_as_comments/ #2

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Add comments to your Hugo blog linked to Github issues with utterances | Travis Dent

Disqus sucks and most tech folk have a Github account so how about using Github issues to support comments.

http://localhost:1313/posts/2021_11_28_github_issues_as_comments/

pugillum commented 2 years ago

Dear sir

Hello dear friend, this is a splendid article. 🍻

Ooh look, a table 🧐 tables in markdown
are fun
tuket commented 2 years ago

Thanks!

GerBreOwn commented 2 years ago

What if the user does not have a GitHub account? How can they post comments then? Thanks.

tuket commented 2 years ago

What if the user does not have a GitHub account? How can they post comments then? Thanks.

Not possible. You need a github account.

pugillum commented 2 years ago

It is indeed as @tuket says. Without some form of authentication one is likely to end up with a bunch of spam comments. And in the world of tech blogs most readers tend to have a Github account. The alternative is Disqus but that would also require setting up an account.

GerBreOwn commented 2 years ago

Would it also be wise to have a link on my site saying: "If you do not have a GitHub account, CLICK HERE to sign up for one"?

GerBreOwn commented 2 years ago

Is there a way to NOT include utterances on all pages? Just on certain blog pages? Thanks

tuket commented 2 years ago

Is there a way to NOT include utterances on all pages? Just on certain blog pages? Thanks

Yes. For example, you could edit you "comments.html" to take into account a "comments" parameter.

{{ if or (not (isset .Params "comments")) (.Params.comments) }}
<script src="https://utteranc.es/client.js"
  repo="username/username.github.io"
  issue-term="pathname"
  label="💬💬"
  theme="gruvbox-dark"
  crossorigin="anonymous"
  async>
</script>
{{ end }}

In that way, you have comments by default in all the pages that include "comments.html". But you can also set the "comments" param to false to avoid it.

---
layout: past
title: My title
published: true
comments: false
---

blabla
GerBreOwn commented 1 year ago

I am just now getting back to my project and am still having problems with the contact form showing up on all of my pages even after following the above instructions. Especially in my home page I am not able to find the file to add "comments: false". On some of the blog pages "*.md" at the top of the file I have added "comments: false" but they are still showing up. Any other suggestions? Thanks.

GerBreOwn commented 1 year ago

It has been awhile since I have been working on this but I am still having the same problem with the comments box showing up on ALL pages. I have comment it out in my config.yaml file. I then uncommented it and then set enable: false. Nothing seems to be working. Any other suggestions on how I can make it show up on only certain pages? Thanks

tuket commented 1 year ago

That's all you need to know, really. My suggestion is to try to understand how things work, experiment, use different debugging techniques.

For example, take any particular page. How does that page include the utterances script?

<script src="https://utteranc.es/client.js"
  repo="username/username.github.io"
  issue-term="pathname"
  label="💬💬"
  theme="gruvbox-dark"
  crossorigin="anonymous"
  async>
</script>

Try to find where that script is located. How do you know is the right one? Easy, delete it, and see if the comment section disappears for that page.

Once you have found the right script, you will have to wrap it with an if condition. Start with something simple.

{{ if false }}

And start building up from there.

Read the documentation: https://gohugo.io/templates/introduction/#conditionals

In summary: read the docs, understand how things work, experiment.

Good luck!