安知鱼主题配置
发表于更新于
字数总计:1.2k阅读时长:4分钟 深圳
博客搭建主题配置安知鱼主题配置
Frank Dum
安知鱼博客主题安装
1. 主题安装
- Github安装:
进入到博客的根目录,执行如下质指令:
1
| git clone -b main https://github.com/anzhiyu-c/hexo-theme-anzhiyu.git themes/anzhiyu
|
或者使用url代理安装
1
| git clone -b main https://ghproxy.com/https://github.com/anzhiyu-c/hexo-theme-anzhiyu.git themes/anzhiyu
|
- 下载最新release版本,解压到(…/…/themes),并重命名文件夹名为anzhiyu


注意:建议使用Github安装,方便后续更新,也无需解压等操作
2. 应用主题
打开博客根目录下的config.yml,搜索theme,将theme配置项改anzhiyu
1 2 3 4
| # Extensions ## Plugins: https://hexo.io/plugins/ ## Themes: https://hexo.io/themes/ theme: anzhiyu
|
3. 安装 pug 和 stylus 渲染插件
1
| npm install hexo-renderer-pug hexo-renderer-stylus --save
|
4. 覆盖配置
将主题配置放在./themes/anzhiyu目录之外,避免后续更新anzhiyu主题丢失自定义的配置
复制/themes/anzhiyu/_config.yml此文件到 hexo 根目录,并重命名为_config.anzhiyu.yml,后续针对主题的配置修改都只需要修改_config.anzhiyu.yml即可。针对同名的配置,_config.anzhiyu.yml的配置优先级高于原 _config.yml
注意: 每次更新主题可能存在配置变更,请注意更新说明,可能需要手动对 _config.anzhiyu.yml 同步修改。
安知鱼主题配置
安知鱼主题配置比较丰富,以下罗列个人常用的配置:
1.全局配置
整个博客都生效的配置。
语言设置
修改的配置文件_config.yml(原生配置文件)
1 2 3 4 5 6 7 8 9 10
| # 配置网站的标题,副标题等个人资料;注意可能会被_config.anzhiyu.yml配置覆盖 title: FDBlog subtitle: 欢迎来到我的博客 description: '' keywords: author: Frank Dum # default(en) zh-CN (简体中文) zh-TW (繁体中文) language: zh-CN ## 设置站点的url.如果博客挂载在GitHub Page, 可以设置url为 'https://username.github.io' url: http://fdlearn.top
|
导航配置
修改_config.anzhiyu.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| menu: 文章: # 隧道: /archives/ || anzhiyu-icon-box-archive 分类: /categories/ || anzhiyu-icon-shapes 标签: /tags/ || anzhiyu-icon-tags
# 友链: # 友人帐: /link/ || anzhiyu-icon-link # 朋友圈: /fcircle/ || anzhiyu-icon-artstation # 留言板: /comments/ || anzhiyu-icon-envelope
# 我的: # 音乐馆: /music/ || anzhiyu-icon-music # 追番页: /bangumis/ || anzhiyu-icon-bilibili # 相册集: /album/ || anzhiyu-icon-images # 小空调: /air-conditioner/ || anzhiyu-icon-fan
# 关于: # 关于本人: /about/ || anzhiyu-icon-paper-plane # 闲言碎语: /essay/ || anzhiyu-icon-lightbulb # 随便逛逛: javascript:toRandomPost() || anzhiyu-icon-shoe-prints1
|
必须是 /xxx/,后面||分开,然后写图标名。

导航栏配置
修改_config.anzhiyu.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| # nav相关配置 nav: enable: true travelling: false clock: false menu: - title: 网页 item: - name: 博客 link: https://hexo.anheyu.com/ icon: /img/favicon.ico - title: 项目 item: - name: 安知鱼主题 link: https://docs.anheyu.com/ icon: https://image.anheyu.com/favicon.ico - name: Hexo link: https://hexo.io/zh-cn/docs/ icon: https://hexo.io/favicon.ico
|

代码块配置
修改_config.anzhiyu.yml
1 2 3 4 5 6 7 8
| # Code Blocks (代码相关) # -------------------------------------- highlight_theme: mac light # 共6种高亮样式 darker / pale night / light / ocean / mac / mac light / false highlight_copy: true # copy button 复制按钮 highlight_lang: true # show the code language 代码语言 highlight_shrink: false # true: 全部代码框不展开,需点击>打开 / false: 代码框展开,有>点击按钮 | none: 不显示>按钮 highlight_height_limit: 330 # unit: px code_word_wrap: false
|
Hexo博客中代码块引入方式如下,如果不正常引入代码块,可能代码高亮样式不生效:
1 2 3 4 5 6 7 8 9 10 11
| {% codeblock [title] [lang:language] [url] [link text] [additional options] %} code snippet {% endcodeblock %}
{% code [title] [lang:language] [url] [link text] [additional options] %} code snippet {% endcode %}
``` [language] [title] [url] [link text] [additional options] code snippet ```
|
上面的第三种是 Markdown 的 fenced code block 语法。当代码块嵌套时可使用第三种在外层,嵌套codeblock

链接使用相关示例:
-
行内链接: 官方文档
-
链接到站内文章: 我的第一篇文章
-
HTML 链接语法: GitHub
-
邮件链接: 有问题?联系我
-
适合多次使用相同链接的情况: 参考链接 和 备用链接
1 2 3 4 5 6 7 8 9 10
| 1. [官方文档](https://hexo.io/zh-cn/docs/) 2. <a href="/2025/12/27/hello-world/" title="Hello World">我的第一篇文章</a> 3. <a href="https://github.com" target="_blank">GitHub</a> 4. 有问题?[联系我](mailto:me@example.com)
[参考链接][1] 和 [备用链接][2]
[1]: https://reference.com [2]: https://backup.com
|
使用 Markdown 嵌入图片:
1 2 3 4
| #默认的 Hexo 安装会包含一个使用 marked 的 markdown 渲染器插件,所以如果你想用 hexo-renderer-markdown-it,就必须移除它。 npm un hexo-renderer-marked --save #如果你已经移除了默认渲染器,以及可能添加的其他插件,现在可以安全安装 hexo-renderer-markdown-it npm i hexo-renderer-markdown-it --save
|
然后在_config.yml配置文件中添加如下配置:
1 2 3 4
| post_asset_folder: true marked: prependRoot: true postAsset: true
|
使用如下方式在md文件中引入图片: