个人博客搭建笔记----hexo踩坑记录

1. post.excerpt摘要没有显示出来

需要在文章里面添加

<!-- more -->

该注释标签上面的内容即为摘要

2. post.excerpt摘要没有按html解析,按文本解析

使用的时候写成

<%= post.excerpt %>

不该写成<%=,应该写成<%-

<%- post.excerpt %>

3. hexo deploy发生错误

执行hexo deploy出现报错
ERROR Deployer not found: git
执行

npm install --save hexo-deployer-git

再执行
hexo deploy就不会了

4. 使用site.posts[0]时出错

我在使用site.posts时,使用forEach的语法的时候,可以遍历文章内容,但是通过索引(site.posts[0])获取文章内容的时候就失败了,而打印site.posts.length是有值的

把site.posts打印出来才发现,site.posts的结构是这样的。。。

{
    data:[
        // ...实际的文章内容
    ],
    length:n, // n为文章的数量
    // ...
}

所以就改用site.posts.data[0]了

5. hexo部署时发生错误Unhandled rejection Nunjucks Error:

是md文件里面某个出错了,可能要具体去排查
我这里出现的问题是写了
{{}}

只要在第一个{前面加上反斜杠\即可

发布了195 篇原创文章 · 获赞 14 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/zemprogram/article/details/104446065