Skip to content

Instantly share code, notes, and snippets.

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

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

This comment has been minimized.

Copy link

@kiarafbickers kiarafbickers commented May 2, 2017

How would I get just the comment count number?


This comment has been minimized.

Copy link

@arbaev arbaev commented May 30, 2017

@kiarafrobles check this instructions:

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.