Skip to content

Instantly share code, notes, and snippets.

@haacked
Created December 10, 2013 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haacked/7885542 to your computer and use it in GitHub Desktop.
Save haacked/7885542 to your computer and use it in GitHub Desktop.
Disqus Jekyll template include
{% comment %} Load script if disquss comments are enabled and `page.comments` is either empty (index) or set to true {% endcomment %}
{% if site.disqus_short_name and page.comments != false %}
<script type="text/javascript">
var disqus_shortname = '{{ site.disqus_short_name }}';
{% if page.comments == true %}
{% comment %} `page.comments` can be only be set to true on pages/posts, so we embed the comments here. {% endcomment %}
// var disqus_developer = 1;
var disqus_identifier = '{% if page.disqus_identifier %}{{ page.disqus_identifier}}{% else %}{{ site.url }}{{ page.url }}{% endif %}';
var disqus_url = '{{ site.url }}{{ page.url }}';
var disqus_script = 'embed.js';
{% endif %}
(function () {
{% if page.comments == true %}
var embedScript = document.createElement('script');
embedScript.type = 'text/javascript';
embedScript.async = true;
embedScript.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(embedScript);
{% endif %}
var countScript = document.createElement('script');
countScript.type = 'text/javascript';
countScript.async = true;
countScript.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(countScript);
}());
</script>
{% endif %}
@engr-hasanuzzaman
Copy link

Nice

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