Disqus评论在本地主机上托管时显示,但在GitHub Pages上托管时不显示。

3
我使用Jekyll创建了一个博客类型的页面,并使用GitHub pages进行托管。我最近尝试添加disqus评论;当我在目录内运行Jekyll serve并通过localhost:4000访问我的页面时,评论出现并且功能完整。问题出现在我推送更改并尝试通过浏览器(grilla99.github.io)访问时,更改不会显示。为什么会发生这种情况?
我的post.html如下:

<article class="post" itemscope itemtype="http://schema.org/BlogPosting">

  <header class="post-header">
    <h1 class="post-title" itemprop="name headline">{{ page.title | escape }}</h1>
    <p class="post-meta">
      <time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">
        {% assign date_format = site.minima.date_format | default: "%b %-d, %Y" %}
        {{ page.date | date: date_format }}
      </time>
      {% if page.author %}
        • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>
      {% endif %}</p>
  </header>

  <div class="post-content" itemprop="articleBody">
    {{ content }}
  </div>

    {% include disqus_comments.html %}
</article>

我的disqus_comments.html文件看起来像这样:

{% if page.comments %}
<div id="disqus_thread"></div>
<script>

/
*  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
*  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/

var disqus_config = function () {
// this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = grilla99-github-io; 
};

(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://grilla99-github-io-1.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">comments powered by Disqus.</a></noscript>
{% endif %}
                            

在我的YAML中,我已经设置了在我的帖子页面上显示评论,如下所示:

comments: true

为什么在线时没有显示评论,我该怎么修复它?

2个回答

0
替换以下代码
this.page.identifier = grilla99-github-io;

使用

this.page.identifier = '{{ page.url | absolute_url }}'; 

这是因为您的网站没有使用您在问题中发布的disqus_comments.html,而是使用了Minima主题中的disqus_comments.html - ashmaroli

0

我看到你在使用默认的Jekyll主题来建立你的网站。 只需要将以下内容添加到你的配置文件中就足够了。

  disqus:
    shortname: my_disqus_shortname

这个是有用的,因为它将disqus注册为尝试显示评论区域。然而,它显示了以下内容:'我们无法加载Disqus。如果您是管理员,请查看我们的故障排除指南。' - Grilla99
我会查看故障排除指南,我的代码中是否有明显的问题可能导致这个? - Grilla99
删除您的存储库中的 _site.sass-cache 文件夹。GitHub Pages 将自动创建这些文件夹。然后将这两个路径添加到名为 .gitignore 的文件中,并将该文件添加到您的存储库中。 - ashmaroli

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接