此文总结了本人用hexo建博客时碰到的一些问题

hexo常用命令

1
2
3
4
hexo n #写文章
hexo g #生成静态页面
hexo d #部署到github
hexo s #本地启动

问题汇总

问题一:执行hexo d总报错

本机执行环境:hexo -v

1
2
3
4
5
6
7
8
9
10
hexo: 3.1.1
os: Windows_NT 10.0.10240 win32 x64
http_parser: 2.5.0
node: 4.1.0
v8: 4.5.103.33
uv: 1.7.4
zlib: 1.2.8
ares: 1.10.1-DEV
modules: 46
openssl: 1.0.2d

部署配置为

1
2
3
4
5
deploy:
type: git
#repo: https://github.com/Chiva-Zhao/jobar.github.io.git
repo: git@github.com:Chiva-Zhao/chiva-zhao.github.io.git
branch: master

执行hexo d报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
nothing to commit, working directory clean
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No error
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No error

at ChildProcess.<anonymous> (D:\workspace\blog\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:42:17)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:817:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

分析:本机装了gitTortoiseGit,执行deploy时候跟环境变量指定的TortoiseGit有冲突,干掉相关的环境变量:”SVN_SSH” or “SSH”等含有TortoiseGit.exe的环境变量

问题而:部署上去之后访问不了,github报404错误

分析:github要求你必须要用username.github.io来命名你的scheme。刚开始建的xxx.github.io是不能用的,必须要用你github的username来建,了解了原因之后就好说了,重新改名为我的username.github.io.搞定!
具体参考这里

问题三:配置关于菜单

  1. 在博客主目录的source下建about目录
  2. 新建一个index.md文件输入内容
    1
    2
    3
    # 关于我

    爱生活,爱编程

问题四:RSS订阅不起作用

  1. 安装hexo-generator-feed插件

    1
    npm install hexo-generator-feed --save
  2. 执行hexo g & hexo s,发现public文件夹下已生成atom.xml,搞定!

问题五:中英文以及中文乱码问题

需要把你编辑的博客文件保存为UTF-8的格式
另外在_config.yml文件中配置language选项
language: zh-CN

问题六:如何配置分类和标签?

  1. 在博客主目录的source下新建categoriestags目录,里面分别放一个index.md文件
  2. 内容分别为
    1
    2
    3
    4
    5
    layout: categories
    title: categories

    layout: tags
    title: tags

在写博客的时候前面文章前面加入:
tags: [hexo,RSS, github] 多个标签用[]括起来,,做为分隔符
categories:issues
hexo会为我们自动进行文章的分类和标签

参考资料

  1. GitHub Pages Basics
  2. jackman 主题使用
  3. hexo你的博客
  4. 最后感谢tiny2014的帮助
文章目录
  1. 1. hexo常用命令
  2. 2. 问题汇总
    1. 2.1. 问题一:执行hexo d总报错
    2. 2.2. 问题而:部署上去之后访问不了,github报404错误
    3. 2.3. 问题三:配置关于菜单
    4. 2.4. 问题四:RSS订阅不起作用
    5. 2.5. 问题五:中英文以及中文乱码问题
    6. 2.6. 问题六:如何配置分类和标签?
  3. 3. 参考资料