主题安装
(npm安装):
npm i hexo-theme-anzhiyu
此方法只支持 Hexo 5.0.0 以上版本 通过 npm 安装并不会在 themes 里生成主题文件夹,而是在 node_modules 里生成
应用主题
打开 Hexo 根目录下的 config.yml, 找到以下配置项,把主题改为anzhiyu
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: anzhiyu
安装 pug 和 stylus 渲染插件
npm install hexo-renderer-pug hexo-renderer-stylus --save
无法安装可以使用cnpm进行安装
npm install hexo-renderer-pug hexo-renderer-stylus --save --registry=http://registry.npmmirror.com
本地启动 hexo
hexo cl
hexo g
hexo s
文章生成永久链接
使用 hexo-abbrlink 的 Hexo 插件来实现文章生成永久链接,安装命令如下:
npm install hexo-abbrlink --save
在 Hexo 根目录下的 _config.yml 文件中,新增以下的配置项:
abbrlink:
alg: crc16 #算法:
rep: hex #输出进制:十进制和十六进制,默认为10进制。丨dec为十进制,hex为十六进制
将 _config.yml 文件中的 permalink 的值修改为如下内容:
permalink: posts/:abbrlink.html # 此处可以自己设置,也可以直接使用 :/abbrlink
执行 hexo clean && hexo g 重新生成博客文件,就可以生成永久链接。生成完后,原 md 文件的 Front-matter 内会增加 abbrlink 字段,值为生成的 ID 。
顶部图
如果不要显示顶部图,可直接配置disable_top_img: true
顶部图的获取顺序,如果都没有配置,则不显示顶部图
主色调相关配置
可以把文章页面顶部颜色从文章中提取对应的颜色显示
mainTone:
enable: true # true or false 文章是否启用获取图片主色调
mode: api # cdn/api/both cdn模式为图片url+imageAve参数获取主色调,api模式为请求API获取主色调,both模式会先请求cdn参数,无法获取的情况下将请求API获取,可以在文章内配置main_color: '#3e5658',使用十六进制颜色,则不会请求both/cdn/api获取主色调,而是直接使用配置的颜色
# 项目地址:https://github.com/anzhiyu-c/img2color-go
api: https://img2color-go.vercel.app/api?img= # mode为api时可填写
cover_change: true # 整篇文章跟随cover修改主色调
文章置顶
hexo-generator-index 从 2.0.0 开始,已经支持文章置顶功能。你可以直接在文章的 front-matter区域里添加 sticky: 1 属性来把这篇文章置顶。数值越大,置顶的优先级越大
字数统计
要为 AnZhiYu 配上字数统计特性, 你需要如下几个步骤:
打开 hexo 工作目录
npm install hexo-wordcount --save or yarn add hexo-wordcount
修改 主题配置文件:
wordcount:
enable: true
post_wordcount: true
min2read: true
total_wordcount: true
搜索功能
安装插件
npm install hexo-generator-search --save
可以在根 _config.yml 中配置这个插件
##Local Search本地搜索
search:
path: search.xml
field: post
format: html
limit: 10000
修改 主题配置文件
local_search:
enable: true
preload: true
CDN: