0%

2025 博客重启!

自从把这个主页对应的 repo 设置为 private,链接也就没法访问了,但是今天又心血来潮重新设置为 public,但是,并没有一键恢复,还是有些东西需要设置的,另外如何新增博客之前没记录,也忘得差不多了,因此呢,索性新建一个,作为博客重启的记录吧。

第一步,设置 GitHub 部署

仅仅将 repo 设置为 public 可不太够, 还需要一些设置,参考:https://docs.github.com/en/pages/quickstart

第二步,安装 hexo 环境

1
2
3
4
>> scoop install nodejs
>> npm install hexo-cli -g
>> npm install # 安装依赖包
>> hexo s # 本地启动

第三步,开始新增博客

1
2
>> hexo n 0082.relaunch-2025
INFO Created: hexo-blog/source/_posts/0082.relaunch-2025.md

第四步,生成 html 文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
>> hexo g
INFO Start processing
INFO Files loaded in 3.16 s
(node:2830) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2830) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:2830) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:2830) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:2830) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:2830) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
INFO Generated: baidusitemap.xml
INFO Generated: search.xml
INFO Generated: sitemap.xml
INFO Generated: index.html
INFO Generated: archives/index.html
INFO Generated: categories/Linux/index.html
INFO Generated: categories/Bug/index.html
INFO Generated: images/cc-by-sa.svg
...
INFO 939 files generated in 7.25 s

然后生成的 html 等文件就会放到 public 文件夹,然后将该文件夹的内容复制到 github.io 文件夹下的 blog 文件夹下,over!

其实当前目录下有个 auto_move.py 脚本,应该是之前写的,里面有两个方法,一个移除多余空格,一个复制到上面提到的 blog 目录下。

遇到的 bug

hexo s 之后本地预览是没毛病的,但是 使用 hexo g 生成的 html 文件都是空的!

最后搜到这篇博客,倒是下面的评论解决了问题:

https://blog.tcs-y.com/2020/04/26/hexo-index-0kb/

搜到了一个github issue,说升级hexo到3.9,我试了下升级hexo到最新6.0.0就好了,node是18。网上搜到的信息全是降级node,可能刚出现这个问题时hexo还没出新版本解决。我跑了一个几年前的项目才出现此问题。

将原先安装的 nodejs 卸载,将当前文件夹下的 node_modules 删除,将当前文件夹下的 package.json 中的 hexo 版本改成 6.0.0。

重新安装 hexo:

1
2
3
>> scoop install nodejs18
>> npm install hexo-cli -g
>> npm install # 安装依赖包

执行完之后,自动更新了依赖,以下为 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
29
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "6.3.0"
},
"dependencies": {
"gitment": "0.0.3",
"hexo": "^6.0.0",
"hexo-deployer-git": "^4.0.0",
"hexo-generator-archive": "^0.1.4",
"hexo-generator-baidu-sitemap": "^0.1.1",
"hexo-generator-category": "^0.1.3",
"hexo-generator-index": "^0.2.1",
"hexo-generator-search": "^2.4.1",
"hexo-generator-searchdb": "^1.3.3",
"hexo-generator-sitemap": "^3.0.1",
"hexo-generator-tag": "^0.2.0",
"hexo-helper-live2d": "^3.1.0",
"hexo-renderer-ejs": "^2.0.0",
"hexo-renderer-marked": "^7.0.1",
"hexo-renderer-stylus": "^0.3.1",
"hexo-server": "^0.3.3",
"hexo-symbols-count-time": "^0.4.4",
"hexo-wordcount": "^6.0.1",
"live2d-widget-model-hijiki": "^1.0.5"
}
}

Welcome to my other publishing channels