以landscape-plus主题为例:
D:\hexo\themes\landscape-plus\layout\_widget\目录下新建 recent_comments.ejs文件,内容如下:

1
2
3
4
5
6
7
8
<% if (theme.duoshuo_shortname){ %>
<div class="widget-wrap">
<h3 class="widget-title"><%= __('最近评论') %></h3>
<div class="widget">
<ul class="ds-recent-comments" data-num-items="5" data-show-avatars="1" data-show-time="1" data-show-title="1" data-show-admin="1" data-excerpt-length="70"></ul>
</div>
</div>
<% } %>

注:其中上述代码第5行<ul class="ds-recent-comments" data-num-items="5" data-show-avatars="1" data-show-time="1" data-show-title="1" data-show-admin="1" data-excerpt-length="70"></ul>按照官方提示可以自行修改:

1
2
3
4
5
6
7
//以下参数均为可选
data-num-items="10" //显示最新评论的条数,最大支持200条
data-show-avatars="1" //是否显示头像,1:显示,0:不显示
data-show-time="1" //是否显示时间,1:显示,0:不显示
data-show-title="0" //是否显示标题,1:显示,0:不显示
data-show-admin="1" //是否显示管理员的评论,1:显示,0:不显示
data-excerpt-length="70"//最大显示评论汉字数

然后在D:\hexo\themes\landscape-plus主题目录中的_config.yml下的widgets中添加recent_comments

1
2
3
4
5
6
7
8
widgets:
- category
- recent_posts
- archive
- tagcloud
- tag
- links
- recent_comments

重新部署后刷新即可。

参考: