Hexo Sooooo Cool

1. 常用命令

  • 更新博客
1
hexo d -g
  • 调试模式
1
hexo s –debug
  • 清理
1
hexo clean

目录

2. Hexo 安装

安装教程
更改主题部分的实例是旧版的,新版Github地址

3. Hexo 配置

3.1. NexT主题个性化设置教程

3.2. 设置背景透明度

修改themes\next\source\css\_custom\custom.styl
增加以下几行

1
.header-inner{
2
    opacity: 0.8;
3
}
4
.main-inner {
5
    opacity: 0.8;
6
}

3.3. icon设置

3.4. 添加tags和categories

3.4. Markdown插入图片

安装插件hexo-asset-image, 注意一定要在博客的根目录运行

1
npm install https://github.com/CodeFalling/hexo-asset-image --save

有时候安装完后不一定显示图片成功, 需要修改下代码.
加载图片失败的原因一般是路径错误.
/node_modules/hexo-asset-image/index.js有一段代码如下

1
var beginPos = getPosition(link, '/', 3) + 1;
2
// In hexo 3.1.1, the permalink of "about" page is like ".../about/index.html".
3
var endPos = link.lastIndexOf('/') + 1;

此处是按照/的位置截取url,按照需求调整选择第几个/就好了

注意: 如果想使代码生效, 需要更改下博客的内容才能让这些代码运行.

3.5. MathJax 数学公式

3.6. 子博客

github库名不同于用户名时,即子网页博客,博客的文章点进去会404

解决:

  1. 创建CNAME文件,内容写入父网页域名(没有http://)
  2. 文件保存在hexo站点文件夹的publicsource里(因为当初百度的时候有人说这个有人说那个,反正我都装了就对了orz)
  3. 站点配置文件_config.yml中修改,如下
1
# URL
2
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
3
url: https://benature.github.io/child.github.io/
4
root: /child.github.io/
  1. hexo d -g .bingo~

4. 报错记录

4.1. 网页加载缓慢(已修复)

console报错记录是

1
GET https://benature.github.io/lib/three/three.min.js net::ERR_ABORTED 404
2
GET https://benature.github.io/lib/three/canvas_lines.min.js net::ERR_ABORTED 404

显然报错原因是路径错误.
通过搜索在\themes\next\layout\_scripts\vendors.swig内有相关设置
再看主题配置文件,有一栏就是vendors,把里面需要的网址反注释出来就好了

4.2. 2018-3-31

1
Error: Connection reset by 13.250.177.223 port 22
2
fatal: sha1 file '<stdout>' write error: Broken pipe
3
fatal: The remote end hung up unexpectedly

4.3. hexo 4.0.0 會給 a 標簽 添加 target=”_blank”

https://github.com/hexojs/hexo/issues/3796


参考资料: