"我们无法加载Disqus." 与jekyll的默认最小主题

nal*_*zok 2 javascript github disqus jekyll github-pages

用jekyll 设置我的个人博客时,我发现我无法显示评论部分.它一直告诉我:

我们无法加载Disqus.如果您是主持人,请参阅我们的故障排除指南.

相关代码:( 有关完整代码,请访问我的代码:https://github.com/sunqingyao/sunqingyao.github.io)

_config.yml

disqus:
  shortname: sled-dog
Run Code Online (Sandbox Code Playgroud)

_layouts/post.html

{% if site.disqus.shortname %}
  {% include disqus_comments.html %}
{% endif %}
Run Code Online (Sandbox Code Playgroud)

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 %}
Run Code Online (Sandbox Code Playgroud)

我已经多次阅读了故障排除指南并检查了每种可能的情况,但评论仍然没有出现.

有几点需要注意:

  1. 我正在使用minima,jekyll的默认主题,并遵循其文档.
  2. 我已经注册了Disqus帐户和经过验证的电子邮件地址.
  3. 我的网站简称是sled-dog.
  4. github.io 已被添加到"可信域".

小智 11

我很惊讶最好的答案是禁用discus.config.

如果您在网站上使用默认的jekyll主题启用disqus时遇到问题,请检查参数.

_config.yml应包括:

disqus: shortname: test-shortname

url: http://yourwebsite.com

JEKYLL_ENV应该设置为"生产"

export JEKYLL_ENV=production

这就是你所需要的.祝好运.


mar*_*nuy 5

this.page.identifier变量中存在错误.

它应该包含页面的唯一标识符,但它当前正在设置页面的URL: this.page.identifier = '{{ page.url | absolute_url }}';

您应该将其更改为:

this.page.identifier = {{ site.disqus.shortname }}';
Run Code Online (Sandbox Code Playgroud)

再见

  • 更新

环绕var disqus_config评论标签:/* var disqus_config = ...*/.