环境准备
依赖环境
1 2 3 4 5 6 7
| git version node -v npm -v
npm config set registry http://registry.npm.taobao.org/
npm config set registry https://registry.npmjs.org/
|
初始化博客
使用npm安装hexo(详细文档),命令是npm install -g hexo-cli
,安装完成之后初始化博客,命令如下:
1 2 3 4
| mkdir sld880311.github.io cd sld880311.github.io hexo init npm install
|
初始化完成之后目录结构如下:
1 2 3 4 5 6 7 8
| . ├── _config.yml ├── package.json ├── scaffolds ├── source | ├── _drafts | └── _posts └── themes
|
常用命令
1 2 3 4 5 6
| hexo s hexo init hexo g hexo clean hexo d hexo clean && hexo g && hexo d
|
特殊配置
配置SSH Key
获取cat ~/.ssh/id_rsa.pub
中的数据,如果没有数据需要按照以下命令配置:
1 2 3
| git config --global user.name "sunliaodong" git config --global user.email "sld880311@hotmail.com" ssh-keygen -t rsa -C 'sld880311@hotmail.com'
|
然后把生成的key添加中自己的github中即可。
部署到github
修改根目录下的_config.yml
1 2 3 4 5 6 7
|
deploy: type: 'git' repo: github: https://github.com/sld880311/sld880311.github.io.git branch: master
|
安装部署插件hexo-deployer-git
1
| npm install hexo-deployer-git --save
|
部署命令
添加字数统计和阅读时长
添加插件
1
| npm install hexo-symbols-count-time --save
|
修改根目录的_config.yml
1 2 3 4 5 6
| symbols_count_time: symbols: true time: true total_symbols: true total_time: true
|
修改主题_config.yml
1 2 3 4 5 6 7 8
|
symbols_count_time: separated_meta: true item_text_post: true item_text_total: true awl: 4 wpm: 275
|
开始写作
1 2 3 4
| hexo new "文章名称" hexo new page categories hexo new page tags hexo new page about
|
参考文档
- theme-next.iissnan
- theme-next.js
- Hexo+Next搭建个人博客
- hexo之主题优化篇
- 超详细Hexo+Github Page搭建技术博客教程【持续更新】
- Hexo+NexT搭建个人博客
- 从头开始搭建hexo+github+hexo-theme-next主题博客(高级设置)