抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

本文记录了本站的运维过程。

运行周期

第 1/4 步:清空缓存

运行 hexo cleanhexo cl 清除缓存文件和以生成的静态文件

第 2/4 步:生成静态文件

运行 hexo generatehexo g 生成静态文件

第 3/4 步:优化

运行 gulp 来进行优化,在本站目前的主要作用是文件压缩

第 4/4 步:部署网站

运行 hexo deployhexo d 部署网站到远程服务器上

也可以运行 hexo serverhexo s 部署网站到本地上,默认可以使用浏览器访问 http://localhost:4000/ 来检查效果

命令简化

可以通过在修改 /package.json 文件中的指定行来简化命令,例如:

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
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "hexo generate",
"clean": "hexo clean",
"deploy": "hexo deploy",
"server": "hexo server",
"cgs": "hexo clean && hexo generate && hexo server",
"cgd": "hexo clean && hexo generate && hexo deploy"
},
"hexo": {
"version": "5.4.0"
},
"dependencies": {
"hexo": "^5.0.0",
"hexo-generator-archive": "^1.0.0",
"hexo-generator-category": "^1.0.0",
"hexo-generator-index": "^2.0.0",
"hexo-generator-tag": "^1.0.0",
"hexo-renderer-ejs": "^1.0.0",
"hexo-renderer-marked": "^4.0.0",
"hexo-renderer-stylus": "^2.0.0",
"hexo-server": "^2.0.0",
"hexo-theme-landscape": "^0.0.3"
}
}

在第10和11行配置了“ cgs ”和“ cgd ”两条命令,用以完成 hexo 的清除缓存、生成静态文件、本地运行和远程部署中的三个步骤。分别使用 npm run cgsnpm run cgd 运行。

更新库

通过安装 ncu 插件可以便利地更新库,运行命令 npm install -g npm-check-updates 以安装 ncu

第 1/3 步:检查更新

1
ncu

第 2/3 步:升级 package.json

1
ncu -u

第 3/3 步:安装更新

1
npm install

优化永久链接格式

通过安装 abbrlink 插件可以基于文章标题生成静态文章链接,运行命令 npm i hexo-abbrlink 以安装 abbrlink

第 1/2 步:修改 config.yml 文件中的永久链接

1
permalink: posts/:abbrlink/

第 2/2 步:更改永久链接设置

1
2
3
4
5
6
7
8
9
10
11
12
13
# abbrlink config
abbrlink:
alg: crc32 #support crc16(default) and crc32
rep: hex #support dec(default) and hex
drafts: false #(true)Process draft,(false)Do not process draft. false(default)
# Generate categories from directory-tree
# depth: the max_depth of directory-tree you want to generate, should > 0
auto_category:
enable: true #true(default)
depth: #3(default)
auto_title: false #enable auto title, it can auto fill the title by path
auto_date: false #enable auto date, it can auto fill the date by time today
force: false #enable force mode,in this mode, the plugin will ignore the cache, and calc the abbrlink for every post even it already had abbrlink.

crc16 和 crc32 分别对应 16 位和 32 位的永久链接,dec 和 hex 分别表示十进制显示和十六进制显示

评论



This is a picture without description

This is a picture without description This is a picture without description This is a picture without description