Skip to content

Instantly share code, notes, and snippets.

@Soreine
Last active January 25, 2019 09:51
Show Gist options
  • Save Soreine/7f717124ffb3cc4e0703 to your computer and use it in GitHub Desktop.
Save Soreine/7f717124ffb3cc4e0703 to your computer and use it in GitHub Desktop.
Jekyll include file to integrate disqus comments.
{% if site.disqus_short_name and page.comments != false %}
<div id="disqus_thread"></div>
<script>
var disqus_shortname = '{{ site.disqus_short_name }}';
var disqus_config = function () {
// _config.yml should define the site's URL
this.page.url = '{{ site.url }}{{ page.url }}';
// Using an optional disqus_identifier variable, or the site.url + page.id combination
this.page.identifier = '{% if page.disqus_identifier %}{{ page.disqus_identifier}}{% else %}{{ site.url }}{{ page.id }}{% endif %}';
};
(function() {
var d = document, s = d.createElement('script');
s.src = '//' + disqus_shortname + '.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" rel="nofollow">comments powered by Disqus.</a></noscript>
{% endif %}
@Soreine
Copy link
Author

Soreine commented Nov 13, 2015

Just place this file in the _include folder and use {% include disqus.html %} anywhere on a page or template. Your _config.yml should set the variable site.disqus_short_name to your site's Disqus shortname and site.url to your site's url. Pages including comments must set page.comments to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment