Skip to content

Instantly share code, notes, and snippets.

@haacked haacked/Disqus.html
Created Dec 10, 2013

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

engr-hasanuzzaman commented May 29, 2016

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.