Allowing comments using giscus#
As my personal website is basically a blog, I’d like readers to be able to comment on it. Previously, I used Disqus for it, but I don’t really like the look and feel of it, and when googling around I found that it is also obnoxious with tracking, adverts and generally disrespecting privacy. One of the alternatives that I was quite charmed by was giscus, a solution that uses GitHub Discussions to power the comments and reactions to my blog posts. In this post, I’ll show how to set up giscus for my Sphinx based website.
The main advantage of giscus is that it works well, looks nice, and is free. The main drawback is that users need to have a GitHub account to be able to react. As I am doing mostly technical writing I figure that most of my readers have a GitHub account already so it shouldn’t be too much of a problem.
Getting this to work is quite straightforward. First, create a repository on GitHub, install the giscus app and select the repository that was just created. Be sure to enable discussions in the repo. Next, follow the instructions on giscus to end up with a code snippet that you can put at the bottom of each page you want to enable comments on. When using MyST markdown, I needed no extra tags to embed it and everything worked out of the box.
<script src="https://giscus.app/client.js" data-repo="[ENTER REPO HERE]" data-repo-id="[ENTER REPO ID HERE]" data-category="[ENTER CATEGORY NAME HERE]" data-category-id="[ENTER CATEGORY ID HERE]" data-mapping="pathname" data-strict="0" data-reactions-enabled="1" data-emit-metadata="0" data-input-position="bottom" data-theme="preferred_color_scheme" data-lang="en" crossorigin="anonymous" async> </script>
The only problem with this approach is that one has to copy paste this snippet in each blog post. In the next post I’ll show how to extend a Sphinx template to include the comment section in each post automatically.
Comments by giscus, use a GitHub account to comment.