Hexo 博客建站和维护记录贴

在新的电脑上部署 Hexo,并保留原有博客的方法

  1. U盘拷贝整个blog文件夹。
  2. 在新的电脑上装好git并配置好用户名和密钥。
  3. 安装 node.js
  4. 安装 hexo:npm install hexo-cli -g
  5. 用U盘把blog文件夹拷贝到新的电脑上。在新电脑上,在blog文件夹中打开终端,输入:npm install。注意,在创建一个新的博客的时候到这一步是hexo init,而由于我们已经要继承之前的设置和博文,所以这一步不能输入hexo init
  6. 至此,完成移植。使用hexo newhexo d -g 等指令测试是否成功吧。

Empty HTML hexo issue

降级 node 到 13 或者 12 。或者升级 hexo 到 4.2.1 及以上。

https://alanlee.fun/2021/02/28/hexo-empty-html/

为页面增加阅读次数

https://hexo-next.readthedocs.io/zh_CN/latest/next/advanced/%E4%B8%8D%E8%92%9C%E5%AD%90-%E6%96%87%E7%AB%A0%E9%98%85%E8%AF%BB%E6%AC%A1%E6%95%B0/

为页面添加密码阅读

https://github.com/D0n9X1n/hexo-blog-encrypt

新增新的 subdirectory 菜单

https://theme-next.iissnan.com/getting-started.html#menu-settings

翻页按钮显示不正常

翻页按钮不正常显示,显示为<i class="fa fa-angle-right"></i>的HTML编码

https://www.cnblogs.com/xiejava/p/12456273.html

为博客添加搜索功能

https://yashuning.github.io/2018/06/29/hexo-Next-%E4%B8%BB%E9%A2%98%E6%B7%BB%E5%8A%A0%E6%90%9C%E7%B4%A2%E5%8A%9F%E8%83%BD/

https://github.com/theme-next/hexo-generator-searchdb

hexo d 遇到权限问题

报错:

1
2
3
4
5
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

原因 Git SSH Key expired.
solution: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key

Upgarde Hexo / Next

1
2
3
4
5
$ hexo --version
hexo: 3.3.7
hexo-cli: 4.3.0
os: win32 10.0.22621
node: 12.16.0

Next compatibility with Hexo version:

https://theme-next.js.org/docs/getting-started/upgrade

It’s recommended to upgrade NexT to version 8 to get the latest features and supports in the new Theme-Next repository. Which means it needs to upgrade hexo to 5.0 or later version first.

Run npm i hexo@5.4.2,

1
2
3
4
5
$ hexo --version
hexo: 5.4.2
hexo-cli: 4.3.0
os: win32 10.0.22621
node: 12.16.0

升级过后测试 hexo -s 遇到一种乱码问题,通过下面方式解决:
https://blog.csdn.net/qq_39898645/article/details/109181736

Upgrade Next (not try)

check next version: go to next _config.yml in the theme next folder, go to the last line, see the version is 5.1.1

Follow this doc to upgrade:
https://theme-next.js.org/docs/getting-started/upgrade#Upgrade-from-Legacy-Version

npm install hexo-theme-next@8.14.2

  1. rename old next folder -> next-old, so that you can switch back to old version anytime.
  2. back up two folder /themes/next, /source/_data
  3. $ npm install hexo-theme-next@8.14.2

todo: https://github.com/theme-next/hexo-theme-next/blob/master/docs/INSTALLATION.md

https://www.imczw.com/post/tech/hexo5-next8-updated.html