快速、简洁且高效的博客框架
以上是 Hexo 官网 的定义.
准备
在使用 Hexo 时需要安装两个软件, 一个是 NodeJS Javascript 的运行时框架, 一个是 Git 版本控制工具, 并将它们添加到系统的环境变量中去.
安装
安装 Hexo 只需要在命令行输入
npm install hexo-cli -g
hexo -v
初始化
安装完 Hexo 后, 我们就可以创建博客啦
hexo init <你的博客名称>
写文章
hexo new "你的文章标题"
启动服务
hexo server
主题
一个好看的主题会抓住用户的眼球
Hexo 默认的主题是 landscape
, 个人觉得太亮眼了, 于是找了个喜欢的 Cafe
git clone https://github.com/giscafer/hexo-theme-cafe.git themes/cafe
部署 GitHub
部署到 github, 生成静态页面
安装插件
npm install hexo-deployer-git --save
hexo generate
hexo deploy
可能遇到的错误
FATAL 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': Invalid argument
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': Invalid argument
解决方法:
_config.yml
中的 git 仓库链接改成 ssh 链接,然后给 git 账户增加 ssh key。
_config.yml
deploy:
type: git
repo:git@github.com:your_github_user_name/your_github_user_name.github.io.git
branch: master
Git Bash Here
$ ssh-keygen -t rsa -C 你的邮箱
然后一直回车跳过就行, 添加到 GitHub 的 SSH keys, 最后再次尝试提交.