Replacing Disqus with Github Comments

I've been considering removing comments from this blog for a while; mainly because the site doesn't trigger much discussion and I didn't like keeping the overhead of Disqus around. After looking into Disqus load-time behaviour I was pretty shocked what I was forcing on people loading the site (although you really should be using the likes of Privacy Badger and uBlock Origin).

This post is Hugo-specific but the very little code required can be adapted to any website.

What's Wrong with Disqus?

This is a typical request log with Disqus enabled:


This is the same request log with Disqus disabled:



Relevant points are:

  • Load-time goes from 6 seconds to 2 seconds.
  • There are 105 network requests vs. 16.
  • There are a lot of non-relevant requests going through to networks that will be tracking your movements.

Among the networks you can find:

  • - Obviously!
  • - Multiple requests; no idea who's capturing your movements.
  • - If you're logged into Facebook, they know you visit this site.
  • - Google will also map your visits to this site with any of your Google accounts.
  • - LiveRamp identify mapping for harvesting your details for commercial gain.
  • - Identity tracking for marketing campaigns.
  • - Pretty suspect site listed as referenced by viruses and spyware.
  • - More identity and movement tracking site which even has a virus named after it!
  • - We all know this one: ad services and movement tracking, owned by Google.
  • - Very shady and tricky to pin-point an owner as they obsfuscate their domain (I didn't even know this was a thing!). Adds a tracking pixel to your site.
  • - More tracking garbage, albeit slightly more prolific.
  • - Advertising and tracking that suppposedly uses machine learning.
  • - Obsfuscated advertising/tracking from Rapleaf.
  • - "Deliver a personalized customer journey across devices, channels and platforms with Adbrain customer ID mapping technology."
  • - Oracle's Datalogix, their own tracking and behavioural pattern rubbish.
  • - OK, I cant't be bothered to search to look this up anymore.
  • - More? Oh, ok, then...
  • - Yup. Tracking.
  • - Tracking. From Adobe.
  • - I'll give you one guess...
  • - ...
  • - Curious name, maybe it's... no. It's tracking you.

I can't visit many of these sites because I have them blocked in uBlock Origin so information was gleaned from google crawl results of the webpages and 3rd parties. Needless to say, it's a pretty disgusting insight into how certain free products turn you into the product. What's more worrying are the services that go to lengths to hide who they are and what their purposes are for tracking your movements.

Anyway. Delete it. I'm sorry for poisoning this site with these networks. Foward to better things...

Using Github for Comments

I was discussing removing Disqus with others and ( mentioned that a friend managed to get comments on their Github-hosted static blog using Pull Requests. I thought this was pretty genius and wanted to figure out if I could do something similar for Hugo on external sites.

The answer came from the Github Issue API. The process is quite simple and is already active on this blog post:

  1. For each blog post you make, open an Issue on some repo on Github. The Issue for this post is here.
  2. All comments are posted directly on Github.
  3. Add some Javascript to your site that reads Github's JSON description of the Issue comments and displays them.

The benefits are immediate:

  • There is zero tracking of you as a reader to this website. Github themselves only see network read requests from unnamed IPs.
  • All comments are written in Markdown, allowing inline code, images, lists and formatting.
  • You can use Github's notifications to informed of responses; you don't even have to visit this site to read and contribute to discussion.
  • Although somewhat superflous, you can also integrate Github Reactions (maybe useful on larger sites).

You don't need an API key to read Github JSON data; it's free for all to access. The comments for this post can be read as JSON here. The first comment looks like:

    "url": "",
    "html_url": "",
    "issue_url": "",
    "id": 295004846,
    "user": {
        "login": "dwilliamson",
        "id": 1532903,
        "avatar_url": "",
        "gravatar_id": "",
        "url": "",
        "html_url": "",
        "followers_url": "",
        "following_url": "{/other_user}",
        "gists_url": "{/gist_id}",
        "starred_url": "{/owner}{/repo}",
        "subscriptions_url": "",
        "organizations_url": "",
        "repos_url": "",
        "events_url": "{/privacy}",
        "received_events_url": "",
        "type": "User",
        "site_admin": false
    "created_at": "2017-04-18T22:39:16Z",
    "updated_at": "2017-04-18T22:39:16Z",
    "body": "This is a comment"

The first step is to add a new template to your partials directory that reads and displays Github comments (comments.html). Here's the code I use:

var url = "" + {{ $.Params.ghcommentid }}
var api_url = "" + {{ $.Params.ghcommentid }} + "/comments"

$(document).ready(function () {
    $.ajax(api_url, {
        headers: {Accept: "application/vnd.github.v3.html+json"},
        dataType: "json",
        success: function(comments) {
            $("#gh-comments-list").append("Visit the <b><a href='" + url + "'>Github Issue</a></b> to comment on this post");
            $.each(comments, function(i, comment) {

                var date = new Date(comment.created_at);

                var t = "<div id='gh-comment'>";
                t += "<img src='" + comment.user.avatar_url + "' width='24px'>";
                t += "<b><a href='" + comment.user.html_url + "'>" + comment.user.login + "</a></b>";
                t += " posted at ";
                t += "<em>" + date.toUTCString() + "</em>";
                t += "<div id='gh-comment-hr'></div>";
                t += comment.body_html;
                t += "</div>";
        error: function() {
            $("#gh-comments-list").append("Comments are not open for this post yet.");

This can then be invoked from your blog post html:

 {{ partial "comments.html" . }}

The variables it references need to be added to the header of your html page. In this case it's the single variable ghcommentid which is set to the number of the Issue used for comments.


There's nothing more beyond that. Technically, you could actually write your blog posts as Github Issues themselves and forgo the need for a blog engine. But that seems too much like using a system in ways it was never intended to be used.

This website is managed on Github as dwilliamson/ It contains the complete code for using Github for your comments.