Add Disqus to Jekyll pages

Published: | Updated: | by Julian Knight Reading time ~1 min.
📖 Kb | 📎 Development | 🔖 Jekyll, Static Site Generators, Disqus

Example code to add to every page as a footer to enable the Disqus comments service.

Create footer.html in your site _includes folder or include this in the default layout in _layouts.

{% if page.comments %}
<div id="disqus_thread"></div>
    var disqus_config = function () { = '{{ page.url | absolute_url }}' = '{{ }}'
    (function() { var d = document, s = d.createElement('script');
    s.src = 'https://<<set_this_from_disqus_settings>>';
    s.setAttribute('data-timestamp', +new Date()); (d.head || d.body).appendChild(s);
<noscript>Please enable JavaScript to view the <a href="">comments powered by Disqus.</a></noscript>
{% endif %}

<div>Updated: {{ | default: site.time | date: "%Y-%m-%d %H:%M" }} <a href="#top">Top</a></div>

Note that the default minima theme for Jekyll/GitHub pages includes a setting for this in _config.yml but currently does not include the appropriate include file to let you use it!

Also note that you have very little control over the styling. In particular, the width is set to 100% so make sure that this code is wrapped in a div that is limited to your normal content width.

comments powered by Disqus