hexo-butterfly主题博客搭建部署
nodejs安装
下载地址:Node.js 中文网
安装步骤略,值得注意的是,http://npm.taobao.org 和 http://registry.npm.taobao.org 域名将于2022年05月31日零时起停止服务,注意及时切换。
npm config set registry https://registry.npmmirror.com
hexo安装
全局安装hexo命令
npm install hexo-cli -g
使用hexo初始化博客文件夹
hexo init xiguapengpeng
进入文件夹,安装hexo相关依赖
# git部署依赖
npm install hexo-deployer-git --save
npm install
至此,可以使用默认主题landscape进行后续部署了,使用其他主题可以参考butterfly安装
# 清除缓存文件db.json和已生成的静态文件夹public
hexo clean
# 生成静态文件
hexo g
# 启动服务本地访问,默认地址为:http://localhost:4000/
hexo s
# 部署之前预先生成静态文件
hexo d
# 组合命令,clean后生成文件,最后部署
hexo g -f -d
butterfly主题安装
通过npm安装会在node_modules里生成主题文件夹
npm i hexo-theme-butterfly
# 如果你没有pug以及stylus的渲染器,请安装
npm install hexo-renderer-pug hexo-renderer-stylus --save
修改Hexo根目录下的 _config.yml,把主题改为butterfly
theme: butterfly
将node_modules\hexo-theme-butterfly\_config.yml
复制到根目录改名为_config.butterfly.yml
,至此butterfly主题安装完成
butterfly主题配置
具体配置项略,参考主题配置
github部署
github注册步骤略
- 头像左侧加号新建仓库
New repository
- 名称必须为
用户名.github.io
,必须指定为public公开仓库,点击Create repository
创建完成
3. 生成个人访问令牌,要及时记录下来,刷新后就不可查看了
4. 修改站点配置文件_config.yml
deploy:
type: git
# 修改为你自己的仓库地址,https://github.com/用户名/用户名.github.io
repo: https://github.com/xiguapengpeng/xiguapengpeng.github.io
branch: master
-
执行部署命令,输入个人访问令牌后会进行静态文件上传,至此部署完毕。稍等片刻,可以访问
https://用户名.github.io/
查看。hexo g -f -d
gitee部署
步骤与github部署类似,略。值得注意的是,gitee使用仓库作为home page的时候需要先审核个人身份证信息,并且在执行部署命令后,需要去仓库进行更新
操作。