将Disqus添加到Github域上的多个[All]页面

时间:2013-07-16 05:11:22

标签: disqus github-pages

由于这个有用的for one of my,我设法正确设置了Disqus article Github页面。
现在我想问一下是否有办法将这个Disqus集成添加到我的所有页面on the domain

P.S。 - 我的所有github页面都有一个footer.html <iframe> d。有什么东西我可以用它来帮助我的目的。有很多站点在所有页面上都有disqus,我该怎么做?

3 个答案:

答案 0 :(得分:1)

据我所知,您希望为博客的每篇文章添加disqus输入。 好吧,Jekyll使用液体模板语言,允许html包含。

我在' _layout '目录中定义了一个布局(例如:default.html)。我在这个文件中放了一个前面的内容告诉Jekyll,当我运行'jekyll build'时我想要解析这个文件。

我还创建了一个disqus.html(在我的 _include 目录中),其中我粘贴了他们提供给我的代码的disqus代码段。 我将此代码段包含在默认布局中(您想要的地方)。 {%include disqus.html%}(我不使用像toto.html那样的文字名称,而是使用变量。但这没关系。我们可以这样做。)

在每篇博文中,在 _post 目录中,在前面我定义'layout:default'

那就是说,如果你没有记住Jekyll文档,那么我的扩展就是 苛刻地理解。所以请随时查看我的博客来源......和手册:)。

http://ihommani.github.io/

啦啦队

答案 1 :(得分:1)

正如chaiyachaiya已经提到的,在Jekyll中使用Disqus非常简单。您只需将此代码放在您希望显示注释线程的位置:

<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = '{{ site.disqus_shortname }}'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script'); s.async = true;
        s.type = 'text/javascript';
        s.src = '//' + disqus_shortname + '.disqus.com/count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

只需编辑{{site.disqus_shortname}},或者您可以在网站的_config.yml文件中指定它

答案 2 :(得分:0)

我在那里,

就像我说的那样,我从Jekyll转向Pelican。 Pelican已经嵌入了您在博客中整合Disqus或谷歌分析所需的所有东西。 您只需在pelicanconf文件中指定disqus域即可。

不再需要手动工作了!就像我说的谷歌分析一样。

你的切换部分可能不那么难。你需要的只是转移你的文章我猜。在gh-pages上发布鹈鹕博客的工作很少。 (这么少)。 我鼓励你看看这个工具。这值得。

http://blog.getpelican.com/