# 1.安装主题
## 主题安装

### 搭建 Hexo 博客
如果你还没有 Hexo 博客,请按照 [Hexo 官方文档](https://hexo.io/zh-cn/docs/) 进行安装、建站。
*包括初始化Hexo项目,应用主题等等*

### **[安知鱼](https://blog.anheyu.com/) 的话**
请注意_config.anzhiyu.yml中的配置优先级大于_config.yml,所以更新主题后需要比对主题文件夹中的theme/anzhiyu/_config.yml 文件内容,一般在release 的说明里会特别提示或给出配置文件版本对比diff,同步修改原配置文件即可。

**tip:**
*本指南经过数个版本打磨,绝大部分的功能都有详细说明,请仔细阅读,节约自己和他人的时间;*
*本指南中提到的:"站点配置" 指的 Hexo 博客目录下的 _config.yml,"主题配置" 指的是 theme/anzhiyu/_config.yml 或者 _config.anzhiyu.yml ,注意区分;*
*本指南中提到的 source 目录都指的是博客目录下的 source 文件夹,不推荐修改主题内 source 目录;*
*每次无论 hexo g 或 hexo s,都最好先使用 hexo clean 清除本地缓存;*
*页面结果以本地 hexo s 为准,部署后的异常大部分是线上缓存原因,在确认没有报错的情况下,等待若干时间后即可正常;*
*由于主题的不同版本会存在配置差异,本指南以最新版本为准。*


本指南不包括所有的配置说明,几乎每个配置在主题配置中都有注释,可配合指南共同参考使用。
另外本指南仅包含主题范围内的使用说明,如果是 Hexo 的使用或者 Hexo 插件的使用,请查阅各自的文档。
若存在其他主题相关的疑问请在 主题作者[issues](https://github.com/anzhiyu-c/hexo-theme-anzhiyu/issues/new) 留言。


#### 主题安装
**温馨提示Anzhiyu主题拥有Main(稳定版)和Dev(测试版)两种版本, 我们推荐您安装使用Github(稳定版)以获得最佳的主题体验**

##### 方式一(Github 推荐):

```bash
git clone -b main https://github.com/anzhiyu-c/hexo-theme-anzhiyu.git themes/anzhiyu
```
如遇安装不上可以使用以下url代理安装

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

##### 方式二(Release 推荐):

下载 [最新 release 版本](https://github.com/anzhiyu-c/hexo-theme-anzhiyu/releases) 解压到 themes 目录,并将解压出的文件夹重命名为 anzhiyu。


##### 方式三(npm安装):

```bash
npm i hexo-theme-anzhiyu
```

此方法只支持 Hexo 5.0.0 以上版本 通过 npm 安装并不会在 themes 里生成主题文件夹,而是在 node_modules 里生成

##### 测试版Dev

```bash
git clone -b dev https://github.com/anzhiyu-c/hexo-theme-anzhiyu.git themes/anzhiyu
```
## 应用主题

打开 Hexo 根目录下的 config.yml, 找到以下配置项,把主题改为anzhiyu

```yml
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: anzhiyu
```

### 安装 pug 和 stylus 渲染插件

```bash
npm install hexo-renderer-pug hexo-renderer-stylus --save
```

无法安装可以使用cnpm进行安装

```bash
npm install hexo-renderer-pug hexo-renderer-stylus --save --registry=http://registry.npmmirror.com
```

#### 覆盖配置

覆盖配置可以使主题配置放置在 anzhiyu 目录之外,避免在更新主题时丢失自定义的配置。

通过 Npm 安装主题的用户可忽略,其他用户建议学习使用。

* *macos/linux 在博客根目录运行*
```bash
cp -rf ./themes/anzhiyu/_config.yml ./_config.anzhiyu.yml
```

* *windows 复制/themes/anzhiyu/_config.yml此文件到 hexo 根目录,并重命名为_config.anzhiyu.yml*

以后如果修改任何主题配置,都只需修改 _config.anzhiyu.yml 的配置即可。

注意:
* 只要存在于 _config.anzhiyu.yml 的配置都是高优先级,修改原 _config.yml 是无效的。
* 每次更新主题可能存在配置变更,请注意更新说明,可能需要手动对 _config.anzhiyu.yml 同步修改。
* 想查看覆盖配置有没有生效,可以通过 hexo g --debug 查看命令行输出。
* 如果想将某些配置覆盖为空,注意不要把主键删掉,不然是无法覆盖的。

## 本地启动Hexo

```bash
hexo cl
hexo g
hexo s
```



# 2.页面配置📕

## 🧱Front-matter 的基本认识

Front-matter 是 markdown 文件最上方以 --- 分隔的区域,用于指定个别档案的变数。其中又分为两种 markdown 里。
** Page Front-matter 用于页面配置
** Post Front-matter 用于文章页配置

**tips:**
***如果标注可选的参数,可根据自己需要添加,不用全部都写在 markdown 里***

```Page Front-matter\
title:
date:
updated:
type:
comments:
description:
keywords:
top_img:
mathjax:
katex:
aside:
aplayer:
highlight_shrink:
type:
top_single_background:
```
```Front-matter
title:
date:
updated:
tags:
categories:
keywords:
description:
top_img:
comments:
cover:
toc:
toc_number:
toc_style_simple:
copyright:
copyright_author:
copyright_author_href:
copyright_url:
copyright_info:
mathjax:
katex:
aplayer:
highlight_shrink:
aside:
swiper_index: 1
top_group_index: 1
background: "#fff"
```

## Page Front-matter

| **写法**              | **解释**                                                                             |
|-----------------------|--------------------------------------------------------------------------------------|
| title                 | 【必需】页面标题                                                                     |
| date                  | 【必需】页面创建日期                                                                 |
| type                  | 【必需】标签、分类、关于、音乐馆、友情链接、相册、相册详情、朋友圈、即刻页面需要配置 |
| updated               | 【可选】页面更新日期                                                                 |
| description           | 【可选】页面描述                                                                     |
| keywords              | 【可选】页面关键字                                                                   |
| comments              | 【可选】显示页面评论模块(默认 true)                                                  |
| top_img               | 【可选】页面顶部图片                                                                 |
| mathjax               | 【可选】显示 mathjax(当设置 mathjax 的 per_page: false 时,才需要配置,默认 false)   |
| katex                 | 【可选】显示 katex(当设置 katex 的 per_page: false 时,才需要配置,默认 false)       |
| aside                 | 【可选】显示侧边栏 (默认 true)                                                       |
| aplayer               | 【可选】在需要的页面加载 aplayer 的 js 和 css,请参考文章下面的音乐 配置              |
| highlight_shrink      | 【可选】配置代码框是否展开(true/false)(默认为设置中 highlight_shrink 的配置)         |
| top_single_background | 【可选】部分页面的顶部模块背景图片                                                   |


## Post Front-matter

|        **写法**       |                                           **解释**                                          |
|:---------------------:|:-------------------------------------------------------------------------------------------:|
| title                 | 【必需】文章标题                                                                            |
| date                  | 【必需】文章创建日期                                                                        |
| updated               | 【可选】文章更新日期                                                                        |
| tags                  | 【可选】文章标签                                                                            |
| categories            | 【可选】文章分类                                                                            |
| keywords              | 【可选】文章关键字                                                                          |
| description           | 【可选】文章描述                                                                            |
| top_img               | 【可选】文章顶部图片                                                                        |
| cover                 | 【可选】文章缩略图(如果没有设置 top_img,文章页顶部将显示缩略图,可设为 false/图片地址/留空) |
| comments              | 【可选】显示文章评论模块(默认 true)                                                         |
| toc                   | 【可选】显示文章 TOC(默认为设置中 toc 的 enable 配置)                                       |
| toc_number            | 【可选】显示 toc_number(默认为设置中 toc 的 number 配置)                                    |
| toc_style_simple      | 【可选】显示 toc 简洁模式                                                                   |
| copyright             | 【可选】显示文章版权模块(默认为设置中 post_copyright 的 enable 配置)                        |
| copyright_author      | 【可选】文章版权模块的_文章作者_                                                            |
| copyright_author_href | 【可选】文章版权模块的文章作者链接                                                          |
| copyright_url         | 【可选】文章版权模块的文章链接链接                                                          |
| copyright_info        | 【可选】文章版权模块的版权声明文字                                                          |
| mathjax               | 【可选】显示 mathjax(当设置 mathjax 的 per_page: false 时,才需要配置,默认 false)          |
| katex                 | 【可选】显示 katex(当设置 katex 的 per_page: false 时,才需要配置,默认 false)              |
| aplayer               | 【可选】在需要的页面加载 aplayer 的 js 和 css,请参考文章下面的音乐 配置                     |
| highlight_shrink      | 【可选】配置代码框是否展开(true/false)(默认为设置中 highlight_shrink 的配置)                |
| aside                 | 【可选】显示侧边栏 (默认 true)                                                              |
| swiper_index          | 【可选】首页轮播图配置 index 索引,数字越小越靠前                                           |
| top_group_index       | 【可选】首页右侧卡片组配置, 数字越小越靠前                                                  |
| ai                    | 【可选】文章ai摘要                                                                          |
| main_color            | 【可选】文章主色,必须是16进制颜色且有6位,不可缩减,例如#ffffff 不可写成#fff               |