【个人博客网站】从零开发博客网站(一)
本篇教程为网站重建后重写
以butterfly主题为例
环境配置
工具下载
Git
进入Git官网,下载好Git
Node.js
进入Node.js官网下载Node.js,也可进入中文站下载Node.js
VSCode
进入VSCode官网,下载VSCode
hexo脚手架安装
新建文件夹,VSCode中打开,打开终端输入以下命令
1 | npm install -g hexo-cli |
hexo本地配置
hexo安装
VSCode中在打开的项目文件夹中,输入以下命令
1 | hexo init |
下载依赖
1 | npm install |
butterfly主题安装
VSCode中在打开的项目文件夹中,输入以下命令
稳定版【建议】
在你的 Hexo 根目录里
1 | git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
测试版
测试版可能存在 bug,追求稳定的请安装稳定版
如果想要安装比较新的 dev 分支,可以
1 | git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
升级方法:在主题目录下,运行git pull
稳定版【建议】
在你的 Hexo 根目录里
1 | git clone -b master https://gitee.com/immyw/hexo-theme-butterfly.git themes/butterfly |
测试版
测试版可能存在 bug,追求稳定的请安装稳定版
如果想要安装比较新的 dev 分支,可以
1 | git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
升级方法:在主题目录下,运行git pull
此方法只支持 Hexo 5.0.0 以上版本
通过 npm 安装并不会在 themes 里生成主题文件夹,而是在 node_modules 里生成
1 | npm i hexo-theme-butterfly |
升级方法:在主题目录下,运行npm update hexo-theme-butterfly
不建议npm安装,后续美化将变得困难
安装插件
1 | npm install |
主题修改
修改根目录下的_config.yml
,把主题改为butterfly
1 | theme: butterfly |
建议
在根目录创建一个文件_config.butterfly.yml
,并把主题目录的_config.yml
内容复制到_config.butterfly.yml
去。(注意: 复制的是主题的_config.yml
,而不是hexo的_config.yml
)
命令集
1 | hexo clean 可简写为: hexo cl |
1 | hexo server 可简写为: hexo s |
1 | heox deploy 可简写为: hexo de (该命令需要安装部署插件并修改hexo配置文件) |
1 | hexo new page 'page name' |
1 | hexo new post 'post name' (也可在source/_post内新建文件) |
1 | hexo三件套: hexo cl&&hexo g&&hexo s |