Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple tip for adding "Disqus" comments for Hexo.

In the footer of your theme (something like footer.ejs) you should add Disqus script:

<% if (config.disqus_shortname){ %>
<script>
  var disqus_shortname = '<%= config.disqus_shortname %>';
  <% if (page.permalink){ %>
  var disqus_url = '<%= config.url +"/"+ page.path %>';
  <% } %>
  (function(){
    var dsq = document.createElement('script');
    dsq.type = 'text/javascript';
    dsq.async = true;
    dsq.src = '//' + disqus_shortname + '.disqus.com/<% if (page.comments) { %>embed.js<% } else { %>count.js<% } %>';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
</script>
<% } %>

Don't forget that Hexo is prepared to use Disqus, so you the another missing thing is to enable it in your _config.yml

# Disqus
disqus_shortname: username
@kiarafbickers

This comment has been minimized.

Copy link

kiarafbickers commented May 2, 2017

How would I get just the comment count number?

@arbaev

This comment has been minimized.

Copy link

arbaev commented May 30, 2017

@kiarafrobles check this instructions: https://help.disqus.com/customer/portal/articles/565624

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.