Adding comments!
One of the most popular way to add support for comments in Jekyll (or other static site generators like Hugo or Hexo) is via Disqus service. Following lines describes how to do that
-
create Disqus account
-
create
_includes/disqus_coments.html
file in your Jekyll project with
content
-
log into Disqus and go to
Admin > Settings > Installation
, choose Jekyll and click on Universal Embed Code link in step 2 -
copy UEC (Universal Embed Code), in my case it looks like
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables */
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://sansajn.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
-
replace line // {paste UEC there} in
_includes/disqus_coments.html
file from step 2 with UEC and save -
copy default minima post layout
post.html
from/var/lib/gems/2.7.0/gems/minima-2.5.1/_layouts
to_layouts
in your Jekyll project
in Ubuntu 20.04 LTS default minima theme is stored in
/var/lib/gems/2.7.0/gems/minima-2.5.1
directory
- open copied
post.html
and add
line just before </article>
closing HTML element and save.
note:
post.html
already containsinclude disqus_comments.html
code insideif site.disqus.shortname
liquid statement so it would be cool to reuse it somehow (drop me a comment if you find out how to do that)
- create new post with
---
layout: post
comments: true
---
hello!
and you should now see Disqus forum at the end of the post.