优化主题anzhiyu

总结

  1. 主题安装
    内容来源:主题安装 | 安知鱼主题官方文档
    方式一
    1
    git clone -b main https://github.com/anzhiyu-c/hexo-theme-anzhiyu.git themes/anzhiyu
    方式二
    下载 最新 release 版本 解压到 themes 目录,并将解压出的文件夹重命名为 anzhiyu
  2. 安装pugstylus渲染插件
    1
    npm install hexo-renderer-pug hexo-renderer-stylus --save
  3. 本地启动Hexo
    1
    2
    3
    4
    5
    hexo cl # hexo clean
    hexo g # hexo generate
    hexo s # hexo server
    ###
    hexo d # hexo deploy 部署到github上
  4. 升级方法

    适用于通过 Github 或 Release 压缩包主题,且没有自行修改任何代码的情况。

(1) 先将原文件夹重命名为别的名称,例如 anzhiyu-bkp,用于升级失败进行回退;
(2) 选择自己的安装方式升级
(3)Github:重新重新执行安装命令即可
Release:按照安装步骤,下载 release 并解压重命名为 anzhiyu
(4) 比对升级后的配置文件_config.yml,如果某些配置发生了变化(改名或弃用),release 的说明里会特别提示或给出配置文件版本对比diff,同步修改原配置文件即可。
ps: 其他的升级方式没写

  1. front-matter的认识
    因为本地要使用obsidian,所以会在obsidian的笔记中配置front-matter,类似于:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    title: 
    date:
    updated:
    type:
    tags:
    categories:
    keywords:
    description:
    top_img:
    cover:
    comments: "true"
  2. 标签页配置
    找到D:\Blog,右键Blog文件夹,选择Open Git Bash here,输入

    1
    hexo new page tags

    找到D:\Blog\source\tags\index.md这个文件,修改文件,添加type: "tags",例如:

    1
    2
    3
    4
    5
    6
    7
    ---
    title: 标签
    date: 2021-04-06 12:01:51
    type: "tags"
    comments: false
    top_img: false
    ---
  3. 分类页配置
    找到D:\Blog,右键Blog文件夹,选择Open Git Bash here,输入

    1
    hexo new page categories

    找到D:\Blog\source\categories\index.md这个文件,修改文件,添加type: "categories",例如:

    1
    2
    3
    4
    5
    6
    7
    ---
    title: 分类
    date: 2021-04-06 12:01:51
    aside: false
    type: "categories"
    top_img: false
    ---
  4. 404页面
    打开D:\Blog\themes\anzhiyu\_config.yml,搜索error_404,将enable置为true

    1
    2
    3
    4
    5
    # A simple 404 page
    error_404:
    enable: true
    subtitle: "页面没有找到"
    background:
  5. 修改站点配置文件 D:\Blog\_config.yml,默认语言是 en,改成
    language: zh-CN

  6. 修改网站各种资料,例如标题、副标题和邮箱等个人资料,请修改博客根目录的D:\Blog\_config.yml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    title: Otherisland
    subtitle: '###'
    description: '###'
    keywords:
    author: Otherisland
    language: zh-CN
    timezone: 'Asia/Shanghai'

    deploy:
    type: git
    repository: git@github.com:###/###.github.io.git #你的仓库地址
    branch: main
  7. 导航配置,修改D:\Blog\themes\anzhiyu\_config.yml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    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/,后面||分开,然后写图标名。

  8. 导航栏设置(默认的还没改)

  9. 代码块配置
    代码高亮主题,darkerpale nightlightoceanmacmac night,修改主题配置文件D:\Blog\themes\anzhiyu\_config.yml

    1
    highlight_theme: mac night

    代码复制(默认):

    1
    highlight_copy: true

    代码框展开/关闭(默认):

    1
    highlight_shrink: true #代码框不展开,需点击 '>' 打开

    pstrue全部代码框不展开,需要点击>打开,false代码块展开,有>点击按钮,none不显示>按钮。
    代码换行(默认):

    1
    code_word_wrap: true

    代码高度限制(默认):

    1
    highlight_height_limit: false # unit: px
  10. 图标设置(还没配置)

  11. 社交图标
    书写格式 名称:url || icon名称

    1
    2
    3
    4
    5
    6
    # social settings (社交图标设置)
    # formal:
    # name: link || icon
    social:
    # Github: https://github.com/Otherisland || anzhiyu-icon-github
    # BiliBili: https://space.bilibili.com/24506641 || anzhiyu-icon-bilibili

    (hover动画相关的还没配置)

  12. 个人卡片(还没改)

  13. 顶部图(现在是给文章top_img配置的)

  14. 文章置顶(还没置顶的)

  15. 文章封面(现在是给文章cover配置的)

  16. 文章meta显示(现在是默认的)

  17. 文章版权(默认的没改)

  18. 文章打赏(默认的没开)

  19. TOC(默认的没改)

  20. 相关文章(默认的没改)

  21. 文章过期提醒(默认的没开)

  22. 文章编辑按钮(默认的没开)

  23. 文章分页按钮(默认的没开)

  24. 中控台(默认的没改)

内容来源

主题简介 | 安知鱼主题官方文档