Reputation: 16107
When setting up my personal blog with jekyll, I found that I cannot get the comments section shown. It kept telling me:
We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Relevant code: (For the complete code, please visit my repo: https://github.com/sunqingyao/sunqingyao.github.io)
_config.yml
disqus:
shortname: sled-dog
_layouts/post.html
{% if site.disqus.shortname %}
{% include disqus_comments.html %}
{% endif %}
disqus_comments.html
{% if page.comments != false and jekyll.environment == "production" %}
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = '{{ page.url | absolute_url }}';
this.page.identifier = '{{ page.url | absolute_url }}';
};
(function() {
var d = document, s = d.createElement('script');
s.src = 'https://{{ site.disqus.shortname }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
{% endif %}
I've read through the troubleshooting guide several times and checked every possible situation, but the comments are still not appearing.
A few things to note:
sled-dog
.github.io
has been added to "Trusted Domains".Upvotes: 6
Views: 4470
Reputation: 2418
In my case, I was using a relative URL for this.page.url
but it should be an absolute URL,
{{ page.url | absolute_url }}
Upvotes: 0
Reputation: 1
Looking at original post by @nazlok, i had a similar issue after googling around, I found out the disqus short_name is not the same as the disqus account name. In fact it is site-specific.
From what I see in your _config.yml , your short_name: sled-dog
could be your 'disqus account name'.
Confirm that you have the correct short_name for your site. See what-is-a-shortname on how to access the short_name.
Upvotes: 0
Reputation: 392
I'm surprised that the best answer is to disable discus.config.
If you have issues to enable disqus on your website with default jekyll theme, please check parameters.
_config.yml should include:
disqus:
shortname: test-shortname
url: http://yourwebsite.com
JEKYLL_ENV should be set to "production"
export JEKYLL_ENV=production
That's all you need. Good luck.
Upvotes: 14
Reputation: 23972
There is an error in the this.page.identifier
variable.
It should contain the page's unique identifier, but it is currently setting the page's url: this.page.identifier = '{{ page.url | absolute_url }}';
You should change it to:
this.page.identifier = {{ site.disqus.shortname }}';
再见
Surround var disqus_config
with comment tags: /* var disqus_config = ...*/
.
Upvotes: 9