hexo创建并免费自动化部署
环境
windows
- 安装
nodejs
- node v20
- 切换镜像源
npm i -g nrm
- 切换淘宝镜像源
nrm use taobao
安装 hexo
- 全局安装
npm i hexo-cli -g
- 初始化项目
hexo init blog
- 进入项目
cd blog
- 安装依赖
npm install
- 启动项目
hexo server
- 全局安装
安装
git
- 下载安装 git
- 配置
git
- 配置用户名
git config --global user.name "your name"
- 配置邮箱
git config --global user.email "your email"
- 配置用户名
- 进入项目目录
cd blogs
- 初始化
git init
- 添加远程仓库
git remote add origin https://github.com/cxvh/blog.git
- 提交
git add .
- 提交
git commit -m "first commit"
- 提交
git push -u origin main
部署项目到
vercel
【完全免费】部署到
github
- 配置
github
仓库- 创建
cxvh.github.io
仓库
- 创建
- 项目安装依赖包:
npm install hexo-deployer-git
- 项目根目录下
_config.yml
文件配置:deploy
type
选择git
repo
输入https://github.com/cxvh/cxvh.github.io.git
branch
选择main
- 配置
"deploy":"hexo deploy"
到package.json
文件的scripts
下- 执行构建:
hexo generate
- 执行部署:
hexo deploy
- 执行构建:
- 访问
https://cxvh.github.io
- 配置
hexo使用
脚手架命令
1 | # 创建文章 |
安装皮肤
- 安装皮肤
npm i hexo-theme-butterfly
- 根目录
_config.yml
文件配置:theme: butterfly
站点地图/搜索引擎收录
1 | # 查看是否被收录 |
配置
内容多标签或多分类配置
1 | tags: [a, b, c] |
基本配置
- 为了得到更好的使用体验,以下内容请务必填写完整,因为这些内容会在主题中得到展示。更多
1
2
3
4
5
6
7title: your title
subtitle: your subtitle
description: your description
keywords: your keywords
author: your name
email: your email
url: your site url
feed 配置
- 参考 hexo-generator-feed
1
2
3
4feed:
type: atom
path: atom.xml
limit: 0
hexo 常见错误整理
端口占用解决方法:关掉占用端口的进程、或者更改端口
hexo s -p 4001
文件命名不能使用 HTML 中有用的字符实体(如:
03.首页:接口定义&组件拆分.md
),否则生成的sitemap.xml
和baidusitemap.xml
无法正常解析
具体参考 字符实体 HTML ISO-8859-1
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 BARAN的小站🔥🔥🔥!