Blog Comments

June 25, 2020   ·   4 min read  ·   Edit on GitHub 

Tagged as:

I recently started blogging, and initially, I wasn’t sure whether or not I was going to allow comments on my blog. A quick search  suggests that there are plenty of arguments both for hosting comments and for avoiding hosting comments. With no clear consensus, how are you supposed to decide which option to go for?

One criterion that I definitely required, were I to host comments on my blog, was that they had to be high-quality and engaging with the content and other commenters. I had no desire to host some relegated spam-ridden permanent garbage fire. As such, I intend to curate my comment section, and I intend to ban any repeatedly disruptive commentators.

Because my web site is a statically generated one, and I wanted it to remain that way, I didn’t want to have to host the comments myself. Some famous comment hosting solutions instantly came to mind: Disqus and Facebook. Were I a little less concerned with topics like user privacy and data security, I probably would’ve slapped a Disqus or Facebook comment section on here, and called it a day. But that was not good enough for me.

I had seen alternatives to comments on some blogs. Dan Abramov , for instance, just puts a link at the bottom of his posts labeled “Discuss on Twitter” that searches Twitter for tweets containing a link back to the post. I briefly considered this solution, but I decided against it based on a few reasons. It’s a bit too detached for my tastes. The only way I’d know somebody had left a comment this way was if they mentioned me in their tweet, or if I went back and looked at those link searches myself to see if anything new had been posted since last time1. Then there’s the character limit. It’s appropriate for what Twitter is, but I don’t want that limit in my comment section. And finally, I’m not an avid Twitter user. I’m not even really an occasional, irregular Twitter user. So putting my blog engagement there wasn’t right for me.

A while back I had come across a comment section somewhere that was hosted using GitHub issues. During my search for a comment section solution, this memory resurfaced. I searched “github comments blog” , which took me to this Stack Overflow question , which finally led me to Jekyll Codex’s “GDPR compliant comments” .

While I’m not using Jekyll to host my blog, nor am I using jQuery, this was close enough to my needs that I could easily adopt it to fit my needs. Here’s how I did it.

I created a BlogComments React component  that takes two properties, gitHubRepository—the repository the comments are stored in (in my case alexschrod/website) and issueId—the id of the issue for the particular blog post. I created a couple of helper components as well; BlogComment, which is responsible for rendering each individual comment and LastRefreshed which shows how long ago the comment section was refreshed. To avoid quickly using up a user’s GitHub API rate limit, comments are cached in local storage and only reloaded upon manual request. I’ve also implemented conditional requests, which are supposed to not count against the rate limit according to their documentation :

Note: Making a conditional request and receiving a 304 response does not count against your Rate Limit, so we encourage you to use it whenever possible.

Unfortunately, I’m observing that my rate limit count goes down even when using conditional requests, so I think there may be an issue with their documentation. I’ve sent a ticket to GitHub about this.

I updated my Blog Post template  to render a comment section if a blog post has an associated comment_issue_id in its frontmatter. That means that if I ever want to have a blog post without comments, I can simply leave out that field, and no comment section will exist.

Finally, I went to my website’s issues page  and created issues for hosting the existing blog post’s comments, and then added the relevant comment_issue_id values to their frontmatter.

And that’s fundamentally it! I think I’ll be fairly happy with this setup. It should meet all my needs for a good comment section hosting solution.

  1. I’m sure there’s some kind of feature on Twitter where you can get a timeline consisting entirely of tweets with links to your blog posts to make doing this easier than having to go back to all your old blog posts and manually check each one. And if there isn’t, Twitter is lacking what would be a decent feature to have.

© 2020 Alexander Krivács Schrøder. CC-BY-SA Some Rights Reserved.  



You can view and leave comments  on GitHub, or the comments below. Last refreshed: Invalid date