Skip to content

Instantly share code, notes, and snippets.

@t3hmun
Last active August 29, 2015 14:00
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 t3hmun/d81556896751186c7798 to your computer and use it in GitHub Desktop.
Save t3hmun/d81556896751186c7798 to your computer and use it in GitHub Desktop.
A modified version of Disqus's universal code for Jekyll posts.
<div id="disqus_thread"></div>
<script type="text/javascript">
/*
This is the Disqus 'Universal Code' modified to work better with Jekyll.
You don't need edit here, edit your _config.yml an your post front-matter.
*/
var disqus_shortname = '{{ site.dqshortname }}'; // Set this var in your _config.yml
/*
Ideally set disqus_identifier to something unique in the front-matter of each post.
You need this identifier to be unique and unchanging to maintain the discussion thread for that post.
By doing this you can ensure that Disqus is unaffected if your post name/date/url gets changed.
If you don't set it then this will fallback to the automatic page.id var '/2012/12/20/my-post'.
Page id is better than full url, because its less likely to be changed.
*/
var disqus_identifier = '{% if page.disqus_identifier %}{{ page.disqus_identifier}}{% else %}{{ page.id }}{% endif %}';
//Below here is identical to what Disqus supply as universal code.
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment