Implementing Disqus Comments in Jekyll

14 Nov 2019

Jekyll is a framework for generating static pages. User input and comments is not static content, so what to do? Well, we may still embed dynamic content, and that’s what the assignment asked us to do:

Visitors should be able to comment on your posts (for instance you could use Disqus)

The installation of Jekyll with the “minima” theme included code for implementing Disqus. I found it needed some modification still.

The site’s post.html layout file includes a reference to a template implementing the Disqus platform in an iframe on the page, on condition that a disqus.shortname variable be defined in _config.yml. The template disqus_comments.html implements Disqus’ provided sample code on condition that the page variable page.comments not be false, enabling simple per page control of comments.

Setting up Disqus was still a bit of a puzzle, which could be traced back to the discrepancy between making a very “capable” framework (Jekyll) for a very simple task (simple, static web pages). There is suddenly the need to know how Jekyll variables work – syntactically and across pages and sites. Not mentioning the fact that the _config.yml needs to be rebooted for changes to take effect, and not knowing whether it’s supposed to be working on localhost or not. It does, even without whitelisting in Disqus advaced settings, but you’ll keep pushing any changes to both dev and production repositories while debugging…

Truth be told though, this is all a first-time problem. Subsequent implementations of both Jekyll and Disqus would have you know most of what you need.

The result should be visible below.