起因
旧的博客站数据丢失,导致各种东西找不回,重新搭建一个新的博客觉得太费时,找到了Hexo
配置环境
- Node
- Git
开始配置
Node安装
Windows
官网下载
https://nodejs.org/en/
我用的是v6.10
安装完使用 node -v 验证下
Mac
- 安装 homebrew
1 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
- brew 升级
1 | brew update |
- 确保brew安全可靠
1 | brew doctor |
修复警告
通过brew安装node和npm
1 | brew link node |
- 测试node和npm安装是否成功
1 | npm install -g grunt-cli |
安装hexo
1 | npm install -g hexo |
博客初始化
1 | cd $work |
完成后 浏览器输入http://localhost:4000
使用github委托
1.需要在github上注册帐号
2.如果你的github用户名为${your_name},仓库名必须为${your_name}.github.io
3.配置_config.yml建立github 和hexo网站的关联
1 | vi _config.xml |
修改最下面
1 | deploy: |
执行命令完成git 部署
1 | npm install hexo-deployer-git --save |
然后发布到github上
1 | hexo deploy(hexo d 简写) |
发布完以后可以到地址访问
hexo 部署相关
以后每次部署都可以按这个来
1 | hexo clean |
列出常用的 hexo 命令
1 | hexo new "postName" #新建文章 |
一些不错的主题列表
Cover - A chic theme with facebook-like cover photo
Oishi - A white theme based on Landscape plus and Writing.
Sidebar - Another theme based on Light with a simple sidebar
TKL - A responsive design theme for Hexo.
Tinnypp - A clean, simple theme based on Tinny
Writing - A small and simple hexo theme based on Light
Yilia - Responsive and simple style 优雅简洁响应式主题,我用得就是这个。
Pacman voidy - A theme with dynamic tagcloud and dynamic snow
使用其他域名委托
可能你有自己的域名
这里可以使用 CNAME 指向
1 | cd source |
hexo插件
1 | npm install --save hexo-filter-flowchart #流程图插件 |
修改域名委托
我是万网的
添加新的解析记录
记录类型为 CNAME
主机记录为 www,如果是子域名这里修改为子域名, blog.yourdomain.com ,这里则填写 blog
记录值为 ${your_name}.github.io
参考
http://www.jianshu.com/p/834d7cc0668d
http://leopardpan.github.io/