本篇为博主的部分魔改重装日记,以防自己日后因魔改迷失所做记录 📝

Hexo与主题安装

1. 安装hexo

1
2
3
4
npm install hexo-cli -g
hexo init
npm install hexo-deployer-git --save
npm install hexo-renderer-pug hexo-renderer-stylus --save

2.安装Anzhiyu

1
git clone -b main https://github.com/anzhiyu-c/hexo-theme-anzhiyu.git themes/anzhiyu

3.应用主题

修改 hexo 配置文件_config.yml,把主题改为anzhiyu

1
theme: anzhiyu

4.安装外挂标签渲染插件

1
2
3
npm install hexo-butterfly-tag-plugins-plus --save
npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save

5.更好的配置,便于升级主题

在博客根目录运行

1
cp -rf ./themes/anzhiyu/_config.yml ./_config.anzhiyu.yml

_config.anzhiyu.yml中的配置优先级大于_config.yml

6.配置文章链接转数字或字母

1
npm install hexo-abbrlink --save

在 config.yml 中修改 permalink

1
permalink: posts/:abbrlink/ 

7.本地启动 hexo

1
2
3
hexo cl
hexo g
hexo s

8.主题升级

升级方法:在主题目录下,运行

1
git pull

或者删除anzhiyu文件夹

主题配置

双栏

如果你需要像我一样首页双栏,修改主题配置文件_config.anzhiyu.yml(主题版本需要 1.1.1 以及以上)

1
2
# 双栏文章
article_double_row: true

字数统计

要为 AnZhiYu 配上字数统计特性, 你需要如下几个步骤:

打开 hexo 工作目录

1
npm install hexo-wordcount --save or yarn add hexo-wordcount

修改 主题配置文件:

1
2
3
4
5
wordcount:
enable: true
post_wordcount: true
min2read: true
total_wordcount: true

留言板:薇尔莉特信封

1
npm install hexo-butterfly-envelope --save

修改配置项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# envelope_comment
# see https://akilar.top/posts/e2d3c450/
# envelope_comment
# see https://akilar.top/posts/e2d3c450/
envelope_comment:
enable: true #控制开关
custom_pic:
cover: https://cdn.cbd.int//hexo-butterfly-envelope/lib/violet.jpg #信笺头部图片
line: https://cdn.cbd.int/hexo-butterfly-envelope/lib/line.png #信笺底部图片
beforeimg: https://cdn.cbd.int/hexo-butterfly-envelope/lib/before.png # 信封前半部分
afterimg: https://cdn.cbd.int/hexo-butterfly-envelope/lib/after.png # 信封后半部分
message: #信笺正文,多行文本,写法如下
- 有什么想问的?
- 有什么想说的?
- 有什么想吐槽的?
- 哪怕是有什么想吃的,都可以告诉我哦~
bottom: 自动书记人偶竭诚为您服务! #仅支持单行文本
height: #1050px,信封划出的高度
path: #【可选】comments 的路径名称。默认为 comments,生成的页面为 comments/index.html
front_matter: #【可选】comments页面的 front_matter 配置
title: 留言板
comments: true
1
留言板: /comments/ || fas fa-envelope

algolia搜索

因为本地搜索如果博客文章变多超过50mb,search.xml会变大,超过2MB,流量消耗太大,所以这里选择algolia

https://github.com/LouisBarranqueiro/hexo-algoliasearch

安装

1
npm install hexo-algoliasearch --save

如果 Hexo 自动检测所有插件,就可以了。

如果不是这种情况,请在您的 _config.yml 文件中配置插件:

1
2
plugins:
- hexo-algoliasearch

配置

在 _config.yml 中配置插件 :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
algolia:
appId: "Z7A3XW4R2I"
apiKey: "12db1ad54372045549ef465881c17e743"
adminApiKey: "40321c7c207e7f73b63a19aa24c4761b"
chunkSize: 5000
indexName: "my-hexo-blog"
fields:
- content:strip:truncate,0,500
- excerpt:strip
- gallery
- permalink
- photos
- slug
- tags
- title

Api 自行前往官网获取

使用

1
hexo algolia

记得要运行 hexo clean