Static Comments For Jekyll

Let There Be Static Comments

About's new comment system and the struggle to attain it

Phew, this was a lot harder than I imagined. But let me say a few words on the general setup of the website itself.

Jekyll uses the Ruby-based website generator Jekyll. Overall, I am indifferent about Ruby as a language (Python is fine, do we really need 100 more scripting languages?). Although, some experiences implementing the RogueNaRok web service using Ruby-on-Rails still haunt me (cue Ruby-RoR-Gem hell). But I am rather enthusiastic about static website generators.

I used wordpress for my previous blog. And while it is easy to install and to use, wordpress just does not fit the average coder’s workflow. As a Linux/Emacs user, you belong to this exotic group of users who prefer to edit raw text files only. Then, extension and configuration of wordpress is rather opaque. It is hard to establish automated pipelines.

That’s where static website generators come into play. You add some pages and blog posts (written in Markdown), fill in some variables and fields and run the generator. Voilà, there’s your static website (i.e., pure HTML, no dynamic content, thus perfect for caching and generally faster than wordpress sites which are loaded from a database typically). Jekyll is blog-aware, that is, it is particularly well-suited for your personal blog served with some portfolio sites around it.

Compared to wordpress, it is straight-forward to apply a version system to your Jekyll site. Regenerating a Jekyll site can be executed as a hook whenever you commit to your repository. Github even offers hosting for your Jekyll site managed via a git repository.

Naturally, I would prefer a website generator written in Python such as Hyde. However, Hyde appears to be vastly less popular than Jekyll and I do not know if there are many themes available for it at all. At this point, I would like to highlight the diversity of themes out there for Jekyll. Moritz Sauer has done an awesome job providing his theme Feeling Responsive which is the basis of this site.

Comments And Non-Staticity

One of the defining aspects of the Web 2.0 is that information flows both ways: you read an article and you instantly can provide feedback which may have even more impact than the original post. Yet, if you want to have comments, your site cannot be purely static and HTML-only. If you add a comment form, there needs to be something that handles the data.

And that is, where things get surprisingly complicated. Jekyll has a plugin system, so you would expect a selection of comment plugins. Well, it turns out, that virtually every Jekyll site uses external comment engines such as Disqus or Poole. These are convenient as they provide a lot of built-in functionality (e.g., users have to have a Disqus-profile) and are dynamically loaded (i.e., you only have to add 3 lines of Javascript code). However, they should be everything but the default commenting system, since this effectively means that the data wander off to some company and you have zero control over it (what happens, if the company ceases to exit?). Ironic new world.

You could hypothetically use discourse as your comment engine (which in its form is potentially superior to any forum) and if you host it yourself, you would be in full control over the data. For installation, discourse requires docker which effectively runs a virtual machine. Virtualization for a comment engine on an otherwise purely static HTML website? Perfectly reasonable!

Static Comments: What is Available

So we finally, come to the few alternatives that exist for static commenting. For one, there is the purely non-dynamic possibility of having users just send comments to token email addresses (e.g., Actually, from the 80ies bearded unix-guy’s perspective, this just seems right: “Send me a message, if it goes through my spam filter, I’ll put it on my page.” And in fact this is the only purely static solution. The downside is that users are not really interacting with your site any more.

Then, finally, alas, finally, there is Jekyll::StaticComments by Matt Palmer (also announced here). Basically, it boils down to: users send you an email via a comment form. Thus, it requires the entire PHP machinery. In principle, you can pass the comments through your mail spam filter, automatically commit the comment to your git repository and auto-regenerate the website. So far, I like the outcome and the possibilities.

But let me open the <rant>-tag: Although the implementation is not too involved, it strikes me as extremely odd that there does not seem to exist more than one static comment plugin for Jekyll. Unexpectedly, the installation was quite tough and did not work without quite some source code inspection. Code from the original git repository is not maintained intensively, but works for Jekyll version 1. For each of the subsequent Jekyll major versions there exist forks that fix the code for this version (here and here). That brings back the old Gem hell memories. To top it off, the feeling responsive theme (using disqus by default) appears to delete the comments in its Ruby code. After fixing, I literally have the following 2 lines in the code:

payload["page"]["comments"] = comments       # fail
payload["page"]["comments2"] = comments      # Ok

So, here it is. Feel free to comment.


From: Dez
2017-02-25 10:55
Hi, This seems interesting enough for me to give it a spin :) in the meantime I have found Staticman tough for the same subject, so I'll spin up a free hosted version of it for hosting comments for multiple sites I develop/run. Thanks,
From: John Ramsden
2017-09-26 23:08
I too use Jekyll for my blog and have been looking for an alternative to disqus. I found Staticman, and it seemed like a good option but I couldn't get it to do anything more useful than send me error messages. It would be great to see a better option out there as I really dislike using disqus for all the reasons you mentioned. I'd rather not run a database in order to have to host my comments as well since that kind of gets rid of the whole point of having a static website.
So far how have you found this option working? Do you get many responses? What is the amount of administration that is necessary to make it work and to moderate the comments?
From: Andre Aberer
2017-09-27 20:44
Hi John, I am in the privileged position of not receiving too many comments. Maybe 1 spam comment in days, that is not too annoying. Even if partly automatized, the work required for each comment is not negligible (copying the comment, committing, pushing, running jekyll and syncing). But the few comments I have gotten, are definitely worth the effort. That extends to your comment: thanks for letting me know! I am considering to use it as a replacement for my current system. While I would prefer being in full control of staticman, it is a weak dependency, as you still fully own the data and one is free to switch the comment engine. It is amazing how github turns into a git-based software environment...

Post a Comment

All comments are held for moderation; Markdown formatting accepted;
By posting you agree to the following privacy policy.

This is a honeypot form. Do not use this form unless you want to get your IP address blacklisted. Use the second form below for comments.
Name: (required)
E-mail: (required, not published)
Website: (optional)
Name: (required)
E-mail: (required, not published)
Website: (optional)