默认主题 landscape

  1. 文件目录,comments为新建的
  2.  
  3. _config.yml
  4.  
  5. layout -- _partial -- article.ejs
  6.  
  7.     |- comments -- disqus.ejs
  8.             |- duoshuo.ejs
  9.             |- youyan.ejs

注册评论系统:

Disqus 注册 设置Shortname

多说  不用注册直接登录(例如用百度账号),设置域名

友言 注册,查看ID


1 修改主题配置文件 landscape/_config.yml 添加以下内容:

  1. # >>> Conments 评论系统 <<<
  2. # Chose ONE as your comment system and keep others disable.
  3. # 选一个作为网站评论系统,其他保持禁用。
  4. disqus:
  5. on: true
  6. shortname: yourshortname
  7. # https://help.disqus.com/customer/en/portal/articles/466208-what-s-a-shortname-
  8. # It is unnecessary to enable disqus here if
  9. # you have set "disqus_shortname" in your site's "_config.yml"
  10.  
  11. duoshuo:
  12. #on: true
  13. domain: yourdomain
  14. # 是否开启多说评论,http://duoshuo.com/create-site/
  15. # 使用上面网址登陆你的多说,然后创建站点,在 domain 中填入你设定的域名
  16. # http://你的多说域名.duoshuo.com
  17.  
  18. youyan:
  19. #on: true
  20. id: yourID
  21. # 是否开启友言评论,http://www.uyan.cc/index.php
  22. # id 中填写你的友言用户数字ID,注册后进入后台管理即可查看
  23. # 友言服务在 Web 环境下运行,普通本地环境无法查看,请部署后在线上测试。
  24.  
  25. # >>> <<<

2 修改 article.ejs 添加:

  1. <% if (!index && post.comments){ %>
  2. <% if (theme.duoshuo.on) { %>
  3. <%- partial('comments/duoshuo', {
  4. key: post.path,
  5. title: post.title,
  6. url: config.url+url_for(post.path),
  7. }) %>
  8. <% } else if (theme.youyan.on) { %>
  9. <%- partial('comments/youyan') %>
  10. <% } else if (theme.disqus.on) { %>
  11. <%- partial('comments/disqus', {
  12. shortname: theme.disqus.shortname
  13. }) %>
  14. <% } else if (config.disqus_shortname) { %>
  15. <%- partial('comments/disqus', {
  16. shortname: config.disqus_shortname
  17. }) %>
  18. <% } %>
  19. <% } %>

3 在comments目录下新建3个文件:disqus.ejs、duoshuo.ejs、youyuan.ejs

  1. # disqus.ejs
  2. <section id="comments">
  3. <div id="disqus_thread"></div>
  4. <script type="text/javascript">
  5. /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
  6. var disqus_shortname = '<%= shortname%>'; // required: replace example with your forum shortname
  7.  
  8. /* * * DON'T EDIT BELOW THIS LINE * * */
  9. (function() {
  10. var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
  11. dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  12. (document.getElementsByTagName('head')[] || document.getElementsByTagName('body')[]).appendChild(dsq);
  13. })();
  14. </script>
  15. <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  16. </section>

  1. # duoshuo.ejs
  2. <div class="duoshuo" id="comments">
  3. <!-- 多说评论框 start -->
  4. <div class="ds-thread" data-thread-key="<%=key%>" data-title="<%=title%>" data-url="<%=url%>"></div>
  5. <!-- 多说评论框 end -->
  6. <!-- 多说公共JS代码 start (一个网页只需插入一次) -->
  7. <script type="text/javascript">
  8. var duoshuoQuery = {short_name:"<%=theme.duoshuo.domain%>"};
  9. (function() {
  10. var ds = document.createElement('script');
  11. ds.type = 'text/javascript';ds.async = true;
  12. ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
  13. ds.charset = 'UTF-8';
  14. (document.getElementsByTagName('head')[]
  15. || document.getElementsByTagName('body')[]).appendChild(ds);
  16. })();
  17. </script>
  18. <!-- 多说公共JS代码 end -->
  19. </div>

  1. # youyuan.ejs
  2. <section class="youyan" id="comments">
  3. <div id="uyan_frame"></div>
  4. <script src="http://v2.uyan.cc/code/uyan.js?uid=<%= theme.youyan.id%>"></script>
  5. </section>

配置完成,可以自由选择使用一种评论系统了!效果如下:


对于maupassant主题,已经自带了disqus、多说 评论系统,只需要在maupassant/_config.yml中开启即可

给hexo添加评论系统的更多相关文章

  1. 接入gitment为hexo添加评论功能

    title: 接入gitment为hexo添加评论功能 toc: false date: 2018-04-16 10:59:56 categories: methods tags: hexo gitm ...

  2. 将hexo的评论系统由gitment改为Valine

    title: 将hexo的评论系统由gitment改为Valine toc: false date: 2018-09-13 15:10:56 categories: methods tags: hex ...

  3. 在Jekyll博客添加评论系统:gitment篇

    最近在Github Pages上使用Jekyll搭建了个人博客( jacobpan3g.github.io/cn ), 当需要添加评论系统时,找了一下国内的几个第三方评论系统,如"多说&qu ...

  4. Hexo瞎折腾系列(8) - 添加评论系统

    前言 Hexo的NexT主题本身就集成了一些评论系统,多说啊之类的已经关闭服务的略过不提,目前比较多人用的有畅言.来必力livere.Gitment.Gitalk.Disqus等. 我刚用的评论系统的 ...

  5. 手摸手带你用Hexo撸博客(三)之添加评论系统

    原文地址 注: 笔者采用的是butterfly主题, 主题内置集成评论系统 butterfly主题开启评论 开启评论需要在comments-use中填写你需要的评论. 以Valine为例 commen ...

  6. hexo博客添加gitalk评论系统

      经过了一天的折腾,我终于为自己的博客添加上了评论系统.坦率的讲,为什么网上那么多方案我还要自己写一篇博客,那就是因为他们说的都有bug,所以我要自己总结一下.   我选用的是gitalk评论系统, ...

  7. Hexo博客yilia主题添加Gitment评论系统

    一开始搭建hexo+yilia博客使用的评论功能是通过来必力实现的.来必力免费,功能多,一开始的体验效果很好,但是后来打开网站发现来必力加载的越来越慢(来必力是韩国的公司,可能是国内限制),遂打算换一 ...

  8. Hexo快速构建个人小站-Fulid主题下添加Valine评论系统(三)

    Hexo目录: Hexo快速构建个人小站-Hexo初始化和将项目托管在Github(一) Hexo快速构建个人小站-自定义域名和自定义主题(二) 背景交代: 前面两章完成了Hexo的初始化和部分自定义 ...

  9. 【干货】2个小时教你hexo博客添加评论、打赏、RSS等功能 (转)

    备注:该教程基于Hexo 2.x版本,目前Hexo是3.x版本,照本教程实现有可能会出现404错误,笔者目前还未找时间去解决,待笔者找时间解决该问题后,再写一篇该问题的解决教程,给各位读者带来困扰,还 ...

随机推荐

  1. mybatis判断list为空

    在传入的map或者对象里面存在一个list,此时想要判断list是否为空,可以 <if test="spids.size()>0 " > and SPid not ...

  2. Python自学笔记——Matplotlib风羽自定义

    [前言]对于气象专业的小学生来说,风场是预报重要的参考数据,我们所知的风羽有四种:短线代表风速2m/s,长线代表风速4m/s,空心三角代表风速20m/s,实心三角代表风速50m/s.而matplotl ...

  3. Java 编译打包命令

    背景 编译 打包 解压 运行 参考 背景 我们有的时候总是要使用将自己写的工程编译成 class 文件,同时打包成 jar,虽然有各种工具可以帮助我们,但是毕竟掌握使用 java 本来的命令去做这些更 ...

  4. [ios2]OS 6 SDK: 在应用内展示App Store【转】

    出于什么样的原因你会希望用户从你的iOS app中进入App Store呢?可能你想用户去App Store 为你的应用评分,也可能你希望用户看到你其他的iOS app.iOS 6引入了SKStore ...

  5. websocket+前后端分离+https的nginx配置

    后端服务路径: 172.168.0.2:8080 172.168.0.2:7080 前端目录(html + css + js): /root/apps/mzsg-web 1.修改 /etc/nginx ...

  6. Amdahl's Law

    Amdahl's Law 程序可能的加速比取决于可以被并行化的部分. 如果没有可以被并行化的部分,则P=0,speedup=1,no speedup. 如果全部可以被并行化,P=1,speedup i ...

  7. winServer2008下安装SqlServer2008数据库

    1 安装文件包 文件名 cn_sql_server_2008_r2_enterprise_x86_x64_ia64_dvd_522233.iso SHA1 0EEFF017B21635DF33F33C ...

  8. php dday1... web服务器的搭建 数据库的安装....

  9. ConfigurationManager 缓存刷新

    服务没有停止的情况下,如果修改了配置,如果不刷新,是不会生效的,需要在每次重新读取配置前刷新配置文件,具体如下: ConfigurationManager.RefreshSection("a ...

  10. 超实用 JS 代码段笔记(一)

    序1:30段简单代码段(有删减) 1 . 区分 IE 和 非 IE 浏览器 if(!+[1,]){ console.log('ie浏览器'); }else{ console.log('非ie浏览器') ...