Adding Disqus comments to a Jekyll blog

2 minute read Published:

Because Jekyll only serves static html pages, I need to use another component/system, that will handle and store the comments for me. Disqus is one of the different solutions out there and is definitely the one that handles the most traffic in the web (interesting read How Disqus Went Realtime With 165K Messages Per Second And Less Than .2 Seconds Latency).

How to setup Disqus in your Jekyll blog

Step1: Sign up for an account

Head to Disqus and sign up for an account. They have a really simple sign up process that gets you started in less than 2min.

Step2: Get the code!

After setting up your site, Disqus will propose install instruction for several blog tools. In our case, you should use “Universal Code”.

Get the code and put save it in _include/comments.html

<div id="disqus_thread"></div>
<script type="text/javascript">
    var disqus_shortname = 'YOUR_SHORTNAME'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = '//' + disqus_shortname + '';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
<noscript>Please enable JavaScript to view the <a href="">comments powered by Disqus.</a></noscript>
<a href="" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

Modify your layouts/post.html and add {% include comments.html %} wherever you want to include the comments (usually… at the bottom!)

And that would be it! Simple!

comments powered by Disqus