# Hexo 入門指南(七) - 評論 & 分享
## 評論 ##
hexo默認集成了disqus,但是在天朝明顯多說更受歡迎一點。
首先到多說官網去注冊一個賬號。然后點擊進入添加站點頁面,填寫所有信息。注意,多說域名的前綴就是站點的短網址,下面要用到,這里假設為short_name。
在_config.yml中添加多說的配置:
```
duoshuo_shortname: short_name
```
修改themes\<theme_name>\layout\_partial\article.ejs,把第38行到41行的如下代碼:
```
<% if (!index && post.comments && config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
<% } %>
```
替換成:
```
<% if (!index && post.comments && config.duoshuo_shortname){ %>
<section id="comments">
<!-- 多說評論框 start -->
<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
<!-- 多說評論框 end -->
<!-- 多說公共JS代碼 start (一個網頁只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= config.duoshuo_shortname %>'};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多說公共JS代碼 end -->
</section>
<% } %>
```
之后,找到第27到29行:
```
<% if (post.comments && config.disqus_shortname){ %>
<a href="<%- post.permalink %>#disqus_thread" class="article-comment-link">Comments</a>
<% } %>
```
替換成:
```
<% if (post.comments && config.duoshuo_shortname){ %>
<a href="<%- url_for(post.path) %>#comments" class="article-comment-link">留言</a>
<% } %>
```
## 分享 ##
hexo默認提供的那四個在國內也被墻了。這里替換成百度一鍵分享。
找到themes\landscape\layout\_partialarticle.ejs26行:
```
<a data-url="<%- post.permalink %>" data-id="<%= post._id %>" class="article-share-link">分享</a>
```
替換成:
```
<a data-url="<%- post.permalink %>" data-id="<%= post._id %>" class="article-share-link bdsharebuttonbox" data-cmd="more">分享</a>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"1","bdMiniList":false,"bdPic":"","bdStyle":"2","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
```
之后打開themes\landscape\source\js\script.js,35~86行全部注釋掉。
## 后記 ##
僅以此教程,悼念Aaron Swartz,RSS和Markdown的聯合創始人。沒有他,開源博客界就不會有今天。
- Markdown 簡介
- Markdown 編輯器推薦
- Markdown 基本語法
- Markdown 高級語法
- Markdown + Gitbook
- Markdown + R
- Markdown + Pandoc
- 用Markdown寫博客:Hexo + Gitcafe
- Hexo 入門指南(一) - 簡介 & 準備
- Hexo 入門指南(二) - 安裝、初始化和配置
- Hexo 入門指南(三) - 文章 & 草稿
- Hexo 入門指南(四) - 頁面、導航、邊欄、底欄
- Hexo 入門指南(五) - 搬家 & 備份
- Hexo 入門指南(六) - sitemap、rss 和部署
- Hexo 入門指南(七) - 評論 & 分享