升级node和npm到最新版

1
2
3
4
5
6
7
8
9
10
11
12
# Step 1: 移除旧版本
sudo yum remove nodejs

# Step 2: 添加 NodeSource 仓库 (以安装 Node.js 18.x 为例)
curl -sL https://rpm.nodesource.com/setup_18.x | sudo bash -

# Step 3: 安装 Node.js
sudo yum install -y nodejs

# Step 4: 验证安装
node -v
npm -v

一键部署

以下教学改编自 一键部署

  1. 安装 hexo-deployer-git
  2. npm install hexo-deployer-git --save
  3. _config.yml 中添加以下配置(如果配置已经存在,请将其替换为如下):
1
2
3
4
5
deploy:
type: git
repo: https://github.com/<username>/<project>
# example, https://github.com/hexojs/hexojs.github.io
branch: gh-pages
  1. 执行 hexo clean && hexo deploy
  2. 浏览 username.github.io,检查你的网站能否运作。

下载主题

git clone https://github.com/henryhuang/hexo-theme-aloha.git themes/aloha

npm install cheerio --save

hexo命令

  1. hexo init blog-source //创建blog-source
  2. hexo new hello-world //创建post布局的页面
  3. hexo g //生成页面
  4. hexo d //发布页面

如何迁移原博客

在原博客源码路径下输入npm install

如何给github pages绑定域名

blog-source的source下添加CNAME文件,内容填写域名比如www.example.com

git绑定repo

  1. git remote add origin git@github.com:xxx/blog-source.git
  2. git push -f origin master