coaching newsletter contact

Discourse Commenting for Jekyll

For years, Disqus has been the commenting platform of choice. It's what I used when my site was on WordPress. When I switched to a static site generated by Jekyll, I pulled commenting entirely. But given the topics I write about, comments can be quite helpful and I realize that was a mistake. So I brought them back with the help of Discourse.

There are a number of reasons I chose Discourse, but suffice it to say that I just like it better than the alternatives, which are actually few in number for static sites. I have a unique way of doing the embed process that I thought other Jekyll users might find helpful.

The Discourse Side

Assuming you have an instance of Discourse running (not the purpose of this post) and you are an admin on said instance, you add the host site as an allowed host in the Discourse settings (Customize → Embedding). That will generate the code you need to embed on each page you want commenting enabled. You'll have to change the embed URL within the code to match the canonical URL of the page it's embedded on. This is what it looks like originally:

The Jekyll Side

This can't get more basic. Paste the code from Discourse to the bottom of the post layout in Jekyll. After I make the edit for the embed URL, this is what the code looks like:

Development Tweaks

Every change I make to the site is previewed before deployment. Each post is reviewed as well. So it's quite normal for me to run jekyll s --future. But I don't want any issues with the embed code when I'm in my development environment, so I tell Jekyll to only add the embed code when the site is being created for production:

{% if jekyll.environment == "production" %}



{% endif %}

Now when I'm ready to deploy my changes I run JEKYLL_ENV=production jekyll b. That sets the environment variable to production instead of development and means the embed code is only included when I'm building the site for real. I use the same trick for my Piwik tracking code. It keeps my external dependencies from creating issues while I am developing.

Thu, Oct 20, 2016 07:00pm CDT https://bhlg.us/4ju1
#discourse #jekyll

Want to see my August 2020 Bullet Journal setup?

Join 1,514 subscribers!

I'll send you the link to a six-minute overview video of my August 2020 spreads when you sign up for my newsletter, The Weekly Impulse.

Site Analytics

I use Fathom Analytics on this site because I care about your privacy. And if you ever want to see the stats collected and the data I see, check out the live analytics here.

Amazon Affiliate

joebuhlig.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means to earn fees when linking to Amazon.com and affiliated sites.

Disclaimer

Disclosure of Material Connection: Some of the links in the post above might be “affiliate links.” This means if you click on the link and purchase the item, I will receive an affiliate commission. Regardless, I only recommend products or services I use personally and believe will add value to my readers. I am disclosing this in accordance with the Federal Trade Commission’s 16 CFR, Part 255: “Guides Concerning the Use of Endorsements and Testimonials in Advertising.”

an analog mind in a digital world

👋 I'm Joe Buhlig. I strive to build productivity systems that stand the test of time and help me do more than check boxes. I'm here to help you do the same.

🎙 I read a lot of books and talk about it.

🐿 I can't focus on one thing for long, so I write a lot of code for an eclectic grouping of projects.

📓 And I'm a bit obsessed with finding non-proprietary solutions to digital problems. Thus, text files for the win! 🎉

MN U.S.A 1986-09-30
  • all
  • articles
  • code
  • likes
  • notes
  • photos
  • replies
  • reposts
  • steps
  • videos
coaching newsletter contact
© 2014-2025 by Joe Buhlig