基于Hexo+GitHub Pages+Melody搭建了自己的个人博客,记录一下在使用过程中遇到的问题和解决方法
1.Hexo解析{{ }}的问题
当Markdown正文中出现{{ }}的时候,Hexo会对其解析不正常,比如:

使用hexo g命令,报错:

解决:在花括号两边分别加上:

使用hexo g命令,执行成功。
2.Melody主题下某些页面去除评论功能
我为博客添加了Gitalk评论插件,但是这样不仅每条博文下有了评论功能,标签页和分类页也被添加了评论功能:


这显然不合理,因此想移除这两个页的评论功能。
解决:很明显需要修改对应页面的生成模版,逻辑在/themes/melody/layout/page.pug:
extends includes/layout.pug
  block content   if page.type === 'tags'     .tag-cloud       .tag-cloud__title= _p('page.tag')         |  -          span.tag-cloud__amount= site.tags.length       - var start_color = theme.theme_color ? (theme.theme_color.tag_start_color || '#A4D8FA'): '#A4D8FA'       - var end_color = theme.theme_color ? (theme.theme_color.tag_end_color || '#1B9EF3') : '#1B9EF3'       .tag-cloud-tags!= tagcloud({min_font: 12, max_font: 30, amount: 200, color: true, start_color, end_color})     if page.comments !== false       include includes/comments/index.pug        else if page.type === 'categories'     #post-content       .category-lists         .category__title= _p('page.category')           |  -            span.category__amount= site.categories.length         div!= list_categories()     if page.comments !== false       include includes/comments/index.pug        else if page.type === 'slides'     include ./includes/mixins/slide.pug     +slideArticle()     if page.comments !== false       include includes/comments/index.pug   else     article#page       h1= page.title       .article-container!= page.content     include includes/pagination.pug     if page.comments !== false       include includes/comments/index.pug
   | 
 
打开/source/tags/index.md:

可以看见标签页的type属性为”tags”,因此删除12&13行代码,即可移除标签页的评论功能。同理,分类页的type属性为”categories”,删除22&23行代码可移除分类页的评论功能。效果如下:

