Hexo config on ubuntu

Git (ubuntu 自带)

1
2
$ git -v
git version 2.43.0
Node.js 安装
1
2
3
4
$ sudo apt install nodejs
. . .
$ nodejs -v
v18.19.1
hexo 安装需要 root 权限
1
2
$ sudo npm i hexo-cli -g
added 53 packages in 4s
进入 blog 目录,安装依赖库
1
$ npm install
本地生成静态网页并打开服务器,测试本地配置无误
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ hexo g
INFO Validating config
INFO ==================================
███╗ ██╗███████╗██╗ ██╗████████╗
████╗ ██║██╔════╝╚██╗██╔╝╚══██╔══╝
██╔██╗ ██║█████╗ ╚███╔╝ ██║
██║╚██╗██║██╔══╝ ██╔██╗ ██║
██║ ╚████║███████╗██╔╝ ██╗ ██║
╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ ╚═╝
========================================
NexT version 8.9.0
Documentation: https://theme-next.js.org
========================================
INFO Start processing
. . .
$ hexo s

配置 github 账户信息
1
2
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
权限问题:
1
2
3
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
创建ssh-key
1
$ ssh-keygen -t rsa -C "you@example.com"
交互全部回车,将产生的 id_rsa.pub 文件中全部内容复制到 github->Access->SSH and GPG keys->New SSH key 并保存,此时再次部署 hexo d 不再有权限问题。

卸载原有渲染器并添加 Mathjax 渲染器,解决 pandoc exited with code null 问题

1
2
$ npm un hexo-renderer-marked
$ npm i hexo-renderer-pandoc
本地需要安装 pandoc
1
$ sudo apt install pandoc

添加 README.md 并使用 hexo ghexo d 部署上传时,md 文件会转换成 html 文件,需要在配置文件 _config.yml 文件中 skip_render 变量下添加:

1
2
3
skip_render:
- lib/**/*
- README.md
重新部署并上传,即可在 github 仓库主页显示 README 栏目。

更换网页背景: 找到 blog/node_modules/hexo-theme-next/source/images 或对应主体目录下的背景文件 canvas.jpg,更换即可。

——博客主页迁移复活完毕。