Embedding Discourse into Hakyll

Posted on August 17, 2014
Tags: hakyll

Discourse is a great open sorce forum software. With the recent versions it is now also possible to embedd discourse as comment platform for you blog. It turned out to be fairly simple when using hakyll.

First you should configure hakyll so that an atom feed is created, by following the tutorial at http://jaspervdj.be/hakyll/tutorials/05-snapshots-feeds.html

Then simple add the following template to your posts template at templates/post.html

<div id="discourse-comments"></div>

<script type="text/javascript">
  var discourseUrl = "http://forums.geekplace.eu/",
      discourseEmbedUrl = 'http://geekplace.eu/flow$url$';

  (function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
      d.src = discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);

And configure discourse at Site Settings → Embedding as described in http://eviltrout.com/2014/01/22/embedding-discourse.html