butterfly主题安装
本文简单介绍一下butterfly主题的安装过程。
1 安装butterfly
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令进行安装:
1 | git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令进行安装:
1 | git clone -b master https://gitee.com/iamjerryw/hexo-theme-butterfly.git themes/butterfly |
Hexo版本必须在5.0.0以上!
1 | npm i hexo-theme-butterfly |
2 应用butterfly
在博客根目录下修改站点配置文件_config.yml
,将主题应用为butterfly
:
1 | # Extensions |
3 安装插件
butterfly
主题需要pug
及stylus
的渲染器,打开终端,在博客根目录下输入以下命令进行安装:
1 | npm install hexo-renderer-pug hexo-renderer-stylus --save |
4 配置模板
在博客根目录下打开scaffolds
文件夹,对page.md
和post.md
文件进行修改。
修改page.md
文件如下:
1 | --- |
page.md
各参数描述如下所示:
参数 | 描述 |
---|---|
title | 页面标题 |
date | 创建日期 |
updated | 更新日期 |
type | 类型,如标签(tag)、分类(categories)、友情链接(link) |
comments | 显示页面评论,默认显示 |
description | 页面描述 |
keywords | 页面关键字 |
top_img | 页面顶部图 |
mathjax | 数学公式mathjax |
katex | 数学公式katex |
aside | 侧边栏 |
aplayer | 音乐播放器 |
highlight_shrink | 代码块是否展开 |
修改post.md
文件如下:
1 | --- |
post.md
各参数描述如下所示:
参数 | 描述 |
---|---|
title | 文章标题 |
date | 创建日期 |
updated | 更新日期 |
tags | 标签,如[‘技术’,’Hexo’] |
categories | 分类,如技术 |
keywords | 文章关键字 |
description | 文章描述 |
top_img | 文章顶部图 |
cover | 文章缩略图 |
comments | 显示文章评论,默认显示 |
toc | 显示目录 |
toc_number | 显示目录标题序号 |
copyright | 显示版权 |
copyright_author | 文章作者 |
copyright_author_href | 文章作者链接 |
copyright_url | 文章链接 |
copyright_info | 版权声明文字 |
mathjax | 数学公式mathjax |
katex | 数学公式katex |
aside | 侧边栏 |
aplayer | 音乐播放器 |
highlight_shrink | 代码块是否展开 |
5 主题配置
5.1 导航目录配置
5.1.1 创建导航目录页面
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令创建归档页面:
1 | hexo new page archives |
对博客根目录source/archives
下的index.md
文件进行如下修改:
1 | --- |
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令创建标签页面:
1 | hexo new page tags |
对博客根目录source/tags
下的index.md
文件进行如下修改:
1 | --- |
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令创建分类页面:
1 | hexo new page categories |
对博客根目录source/categories
下的index.md
文件进行如下修改:
1 | --- |
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令创建友情链接页面:
1 | hexo new page link |
对博客根目录source/link
下的index.md
文件进行如下修改:
1 | --- |
5.1.2 配置导航目录页面
对博客根目录下themes
下的_config.yml
进行编辑,设置导航目录如下:
1 | # 导航目录设置 |
5.2 代码块配置
对博客根目录下themes
下的_config.yml
进行编辑,设置代码块如下:
1 | # 代码块设置 |
5.3 复制配置
对博客根目录下themes
下的_config.yml
进行编辑,设置复制如下:
1 | # 复制设置 |
5.4 社交图标配置
对博客根目录下themes
下的_config.yml
进行编辑,设置社交图标如下:
1 | # 社交图标设置 |
订阅需要安装安装hexo-generator-feed
插件。
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令安装订阅插件:
1 | npm install hexo-generator-feed --save |
安装完成后,对博客根目录下的_config.yml
进行修改,添加如下配置:
注意,是博客根目录下的_config.yml
!
1 | # 订阅 |
5.5 本地搜索配置
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令安装本地搜索插件:
1 | npm install hexo-generator-searchdb --save |
安装完成后,对博客根目录下的_config.yml
进行修改,添加如下配置:
注意,是博客根目录下的_config.yml
!
1 | # 本地搜索 |
5.6 字数统计配置
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令安装字数统计插件:
1 | npm install hexo-wordcount --save |
安装完成后,对博客根目录下themes
下的_config.yml
进行编辑,设置字数统计如下:
1 | # 字数统计 |
5.7 文章过期提醒配置
对博客根目录下themes
下的_config.yml
进行编辑,设置文章过期提醒如下:
1 | # 文章过期提醒设置 |
5.8 评论系统配置
Valine
是一款快速、简洁且高效的无后端评论系统,使用Valine
需要前往LeanCloud进行注册并登陆,进入控制台后点击创建应用
点击创建好的应用,在左侧导航栏选择设置,点击应用凭证查看AppID
和AppKey
。
获取AppID
和AppKey
后,对博客根目录下themes
下的_config.yml
进行编辑,设置评论系统为Valine
:
1 | # 评论系统设置 |
5.9 音乐播放器配置
5.9.1 安装插件
鼠标右键单击选择Git Bash,打开终端,在博客根目录下输入以下命令安装音乐播放器插件:
1 | npm install --save hexo-tag-aplayer |
5.9.2 引入MeingJS
安装完成后,对博客根目录下的_config.yml
进行修改,添加如下配置:
注意,是博客根目录下的_config.yml
!
1 | # 音乐播放器 |
5.9.3 插入代码
然后对博客根目录下themes
下的_config.yml
进行编辑,设置主題的aplayerInject
如下并插入代码:
1 | # Inject the css and script (aplayer/meting) |
其中参数的描述如下所示:
选项 | 默认值 | 描述 |
---|---|---|
data-id | 必须值 | 歌曲 id / 播放列表 id / 相册 id / 搜索关键字 |
data-server | 必须值 | 音乐平台: netease, tencent, kugou, xiami, baidu |
data-type | 必须值 | song, playlist, album, search, artist |
data-fixed | false | 开启固定模式 |
data-mini | false | 开启迷你模式 |
data-listfolded | false | 指定音乐播放列表是否折叠 |
data-order | list | 列表播放模式: list, random |
data-preload | auto | 音乐文件预载入模式,可选项: none, metadata, auto |
data-autoplay | true | 自动播放,移动端浏览器暂时不支持此功能 |
data-loop | all | 列表循环模式:all, one,none |
data-volume | 0.7 | 播放器音量 |
data-lrctype | 0 | 歌词格式类型 |
data-storagename | metingjs | LocalStorage 中存储播放器设定的键名 |
data-mutex | true | 该选项开启时,如果同页面有其他 aplayer 播放,该播放器会暂停 |
data-listmaxheight | 340px | 播放列表的最大长度 |
data-theme | #ad7a86 | 播放器风格色彩设置 |
如果想在页面跳转后,音乐不会中断,需要设置博客根目录下themes
下的_config.yml
文件中的pjax
为true
。
5.10 标签外挂配置
对博客根目录下themes
下的_config.yml
进行编辑,设置标签外挂如下:
1 | # Note (Bootstrap Callout) |
5.10.1 default提示块标签
- simple样式
1
2
3{% note default simple %}
default 提示块标签
{% endnote %}default 提示块标签
- modern样式
1
2
3{% note default modern %}
default 提示块标签
{% endnote %}default 提示块标签
- flat样式
1
2
3{% note default flat %}
default 提示块标签
{% endnote %}default 提示块标签
- disable样式
1
2
3{% note default disable %}
default 提示块标签
{% endnote %}default 提示块标签
5.10.2 primary提示块标签
- simple样式
1
2
3{% note primary simple %}
primary提示块标签
{% endnote %}primary提示块标签
- modern样式
1
2
3{% note primary modern %}
primary提示块标签
{% endnote %}primary提示块标签
- flat样式
1
2
3{% note primary flat %}
primary提示块标签
{% endnote %}primary提示块标签
- disable样式
1
2
3{% note primary disable %}
primary提示块标签
{% endnote %}primary提示块标签
5.10.3 success提示块标签
- simple样式
1
2
3{% note success simple %}
success提示块标签
{% endnote %}success提示块标签
- modern样式
1
2
3{% note success modern %}
success提示块标签
{% endnote %}success提示块标签
- flat样式
1
2
3{% note success flat %}
success提示块标签
{% endnote %}success提示块标签
- disable样式
1
2
3{% note success disable %}
success提示块标签
{% endnote %}success提示块标签
5.10.4 info提示块标签
- simple样式
1
2
3{% note info simple %}
info提示块标签签
{% endnote %}info提示块标签签
- modern样式
1
2
3{% note info modern %}
info提示块标签签
{% endnote %}info提示块标签签
- flat样式
1
2
3{% note info flat %}
info提示块标签签
{% endnote %}info提示块标签签
- disable样式
1
2
3{% note info disable %}
info提示块标签签
{% endnote %}info提示块标签签
5.10.5 warning提示块标签
- simple样式
1
2
3{% note warning simple %}
warning提示块标签
{% endnote %}warning提示块标签
- modern样式
1
2
3{% note warning modern %}
warning提示块标签
{% endnote %}warning提示块标签
- flat样式
1
2
3{% note warning flat %}
warning提示块标签
{% endnote %}warning提示块标签
- disable样式
1
2
3{% note warning disable %}
warning提示块标签
{% endnote %}warning提示块标签
5.10.6 danger提示块标签
- simple样式
1
2
3{% note danger simple %}
danger提示块标签
{% endnote %}danger提示块标签
- modern样式
1
2
3{% note danger modern %}
danger提示块标签
{% endnote %}danger提示块标签
- flat样式
1
2
3{% note danger flat %}
danger提示块标签
{% endnote %}danger提示块标签
- disable样式
1
2
3{% note danger disable %}
danger提示块标签
{% endnote %}danger提示块标签