For a while, I wanted to remove comments from my blog; mainly because there are few comments here at all, and I don’t want to mess around with the extra “brakes” from
Disqus . Looking at the download time of Disqus, I was shocked that I had to endure site visitors through my fault (except for those who use blockers like
Privacy Badger and
uBlock Origin .
This article is designed for Hugo, but the code is easily adaptable for any site.
What is wrong with Disqus?
This is what a typical query log with Disqus
turned on .
')
But the log after
disconnecting Disqus.
WHAT !?The important points are as follows:
- Download time decreases from 6 to 2 seconds.
- The number of network requests is reduced from 105 to 16.
- The network is a mass of irrelevant requests to spy on the user.
Among the network requests you can find such:
- disqus.com - Obviously!
- google-analytics.com - Numerous requests; no idea who is following you.
- connect.facebook.net - If you are logged in to Facebook, they know about your visit to this site.
- accounts.google.com - Google also tracks your visit to this site through any of your Google accounts.
- pippio.com - Identify LiveRamp to collect information about you for commercial purposes.
- bluekai.com - Individual user tracking for marketing campaigns.
- crwdcntrl.net - Quite a suspicious site, which is mentioned in connection with the spread of viruses and spyware.
- exelator.com - Another site to spy on users, in honor of him even named a virus!
- doubleclick.net - We all know that: advertising and surveillance of user actions belongs to Google.
- tag.apxlv.net - Very suspicious and looks like a trick that the owner obfustsiroval his domain (I did not even know that this technique works!). Adds a pixel to your site for surveillance.
- adnxs.com - More tracking junk, albeit a bit more abundant.
- adsymptotic.com - Advertising and surveillance that allegedly uses machine learning.
- rlcdn.com - Obfuscated advertising / tracking from Rapleaf.
- adbrn.com - “We provide user pernalized journey through devices, channels and platforms with the help of matching technology through Adbrain user identifier”.
- nexac.com - Oracle's Datalogix, their own trash for surveillance and behavioral analysis.
- tapad.com - Everything, I'm tired of looking for information about them.
- liadm.com - More? Oh, well, then ...
- sohern.com - Hmm. Snooping.
- demdex.net - Snooping . From Adobe.
- bidswitch.net - I 'll give you one more hint ...
- agkn.com - ...
- mathtag.com - A funny name, maybe it's ... no. It follows you.
I cannot visit many of these sites because they are blocked in uBlock Origin, so I had to collect information from Google search results and from third-party sites. Needless to say, it’s pretty disgusting to see some free products turn you into a product. Even more concerns are caused by services that are trying to hide their purpose and purpose, why they are watching your actions.
In any case, delete it. I apologize to everyone for poisoning your site with these networks. We turn to the best things.
Use Github for comments.
I discussed
disqus deletion, and
@HarryDenholm mentioned that his friend managed to implement comments on his static Github blog using pull requests. I thought it was a great idea, and decided to find out if something could be done for Hugo on an external site.
The answer is in the
Github Issue API . The process is quite simple and it already works for
this blog post :
- For each published post, open the Issue in some repository on Github. For example, for this post it is open here .
- All comments are posted directly to Github.
- Add a Javascript code to the site that reads the description of the JSON comments for this Issue and displays them.
You get the benefits of this approach immediately:
- Tracking site visitors is reduced to zero. Github itself sees only network requests to read from anonymous IP.
- All comments are written on Markdown , with support for embedded code, images, lists, and formatting.
- You can use Github notification of replies; you do not even need to go to this site to read comments and participate in the discussion.
- Although it seems superfluous, you can integrate emoji Github Reactions (may be useful for larger sites).
Github JSON data does not require an API key to read; they are fully open for access. Comments on this post can be read as JSON
here . The first comment looks like this:
{ : , : , : , : 295004846, : { : , : 1532903, : , : , : , : , : , : , : , : , : , : , : , : , : , : , : false }, : , : , : },
The first step is to add a new template to your catalog with parts of the templates. It will read and display Github
comments.html
(
comments.html
). Here is the code I used:
var url = "https://github.com/dwilliamson/donw.io/issues/" + {{ $.Params.ghcommentid }} var api_url = "https://api.github.com/repos/dwilliamson/donw.io/issues/" + {{ $.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>"; $("#gh-comments-list").append(t); }); }, error: function() { $("#gh-comments-list").append("Comments are not open for this post yet."); } }); });
It can be called from the post page:
{{ partial "comments.html" . }}
The variables referenced by the template should be added to the header of the html page. In this case, it is the only
ghcommentid
variable, it sets the Issue number that is used for comments.
Summary
Add nothing more. Technically, you can generally post your posts as Github Issues and forget about the blog engine. But it seems the system is misused.
This website is managed on Github as
dwilliamson / donw.io. There is a complete code for using Github as a comment engine.