hexo博客安装

1.安装Git

1
2
3
4
# 检查是否安装Git
git version
# 安装git
yum install -y git

2.安装Node.js

1
2
3
4
# 检查是否安装
node -v
# 安装node
yum install -y nodejs

3.安装 Hexo

1
2
3
4
5
npm install -g hexo-cli
# 若是 npm报 bash: npm: command not found ,,执行下面三个命令
sudo yum install npm --enablerepo=epel
sudo npm install -g express
sudo npm install -g express-generator

4. 启动 hexo

1
2
3
4
5
hexo init boke
cd boke//进入这个boke文件夹
npm install
hexo g
hexo server

5.安装主题(这里以fluid为例)

1
2
从这里下载主题:https://hexo.io/themes/ 放到themes 目录下并修改配置,主题会
说明怎么操作。

6.发布博客

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1.选择一款Markdown编译器编写文章(以下步骤以csdn为例);
2.编写文章:注册账号登录进去,点击:头像-管理博客,进入文章管理页面,点击左上角
的“Markdown编辑器”;
3.导出文章:文章写好后,在“管理博客”页面点击进入目标文章,点击顶部的“导出选项”,
即可将文章导出到本地;
4.将导出的.md文件复制到hexo博客文件下的/source/_posts文件内;
5.复制完成后,用编译器打开这个文件,在第一行加上title;
---
title: 我的第一篇博客
---
注:这一步用来给文章命名,不按这个格式写的话,在hexo博客上就会显示这个文章没有
名字
只需要在markdown文章开头添加一个<meta name="referrer"
content="no-referrer" />
然后就是hexo clean && hexo g && hexo d上传博客了,这一次分别在电脑和手机
端打开文章,图片显示正常,问题解决。
6.命名结束完成后
输入 hexo g (完整命令为hexo generate),用于生成静态文件;
然后输入 hexo s(完整命令为hexo server),用于启动服务器,主要用来本地预览;
完成后 打开浏览器输入 http://localhost:4000,会发现多了你刚写的那篇博客;
最后输入hexo d(hexo deploy),用于将本地文件发布到github等git仓库上;
7.文章发布完成
8.注意:每次对hexo博客上的博客.md文件进行更改后都要重复步骤6,这样更改的内容才
能在hexo博客上显示

7.Hexo 修改博客站点标题(如果是下载了其他主题,则去其他主题的_congfig.yaml 上更改,每个主题都是不一样的信息)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 网站标题
title: 野猿新一
#网站副标题
subtitle:
#网站描述
description: 野猿新一的博客
keywords: Android Python
#您的名字
author: himmy
#网站使用的语言
language: zh-CN
#网站时区。Hexo 默认使用您电脑的时区。时区列表。比如说:
#America/New_York, Japan, 和 UTC
timezone: America/New_York

8.后台启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
1.安装pm2
npm install -g pm2

2.在博客根目录写一个名为hexo_run.js的脚本
//run
const { exec } = require('child_process')
exec('hexo server',(error, stdout, stderr) => {
if(error){
console.log('exec error: ${error}')
return
}
console.log('stdout: ${stdout}');
console.log('stderr: ${stderr}');
})

3.到博客根目录运行脚本
pm2 start hexo_run.js

pm2的相关命令
pm2 start hexo_run.js #启动
pm2 list #查看pm2管理的所有服务

pm2 stop all #停止pm2列表的所有服务
pm2 stop 0 #停止进程为0的进程

pm2 reload all #重新载入列表所有进程
pm2 reload 0 #重载列表中进程为0的进程

pm2 restart all #重启列表中所有的进程
pm2 restart 0 #重启列表中进程为0的进程

pm2 delete 0 #删除列表中进程为0的进程
pm2 delete all #删除列表中所有的进程

9. 命令

1
2
3
4
5
1.创建分类(nextcloud为分类的名字):hexo n page nextcloud
在每个页面开头加上这个,就可以显示标题跟分类了
title: hexo博客安装
categories:
- nextcloud

hexo博客安装
http://example.com/2025/04/03/hexo博客安装/
作者
zgx
发布于
2025年4月3日
许可协议