Adding disqus to your lektor project

To get in contact with your visitors it is a good idea to provide them the possibility of commenting your posts. Dynamic blog systems like Wordpress can use their own backend for this. A static blog needs help from a special service like disqus. To use discus you have to embed a small JavaScript snippet in your site. Here is a example from my site:

<script>
  var disqus_config = function() { this.page.identifier = "/blog/adding-disqus-to-you-lektor-project"; };
  (function() {
    var d = document, s = d.createElement('script');
    s.src = '//truncated.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());
    (d.head || d.body).appendChild(s);
  })();
</script>

So you are worried you have to put this peace of code in your templates? No need to do this. Lektor will give you a helping hand with the plugin [lektor-disqus-comments](https://github.com/lektor/lektor-disqus-comments).

Bring it up to work is easy:

install

lektor plugins add lektor-disqus-comments

Then create a config file disqus-comments.ini in configs/:

shortname = truncated

Replace "truncated " with the name of your channel. No we are nearly finished. Just add this line of code to the template you will have a disqus comment:

<div class="comments">{{ render_disqus_comments() }}</div>