1、快速安装

1.1 安装

hexo根目录执行

1
2
3
4
5
# Github源
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

# 或者Gitee源
git clone -b master https://gitee.com/immyw/hexo-theme-butterfly.git themes/butterfly
1.2 应用主题

修改hexo目录下的_config.yml文件,设置themebutterfly
thmemes/butterfly/_config.yml文件拷贝到根目录,并改名为_config.butterfly.yml

1.3 安装插件

如果没有安装pug以及stylus的渲染器,需要以下命令行安装

1
npm install hexo-renderer-pug hexo-renderer-stylus --save

2、主题页面

Front-mattermarkdown文件最上方以---分隔的区域,用于指定个别文件的类型。

  • Page Front-matter用于页面配置
  • Post Front-matter用于文章页配置

2.1 Page Front-matter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
title:
date:
updated:
type:
comments:
description:
keywords:
top_img:
mathjax:
katex:
aside:
aplayer:
highlight_shrink:
random:
---
关键词 解释
title 【必须】页面标题
date 【必须】页面创建时间
type 【必须】标签、分类和友情链接三个页面需要配置
update 【可选】更新日期
description 【可选】页面描述
keywords 【可选】关键词
comments 【可选】显示页面评论模块,默认是true
top_img 【可选】页面顶部图片
mathjax 【可选】显示mathjax,当设置mathjax的per_page:false时,才需要配置,默认false
katex 【可选】显示katex,当设置mathjax的per_page:false时,才需要配置,默认false
aside 【可选】显示侧边栏,默认true
aplayer 【可选】在需要的页面加载aplayer的css和js,请参考下面的音乐配置
highlight_sfrink 【可选】配置代码框是否展开(true或者false),默认设置为highlight_shrink的配置
random 【可选】配置的友情链接是否是随机排序,默认为false

2.2 Post Front-matter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
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:
abcjs:
---
关键词 解释
title 【必须】文章标题
date 【必须】文章创建日期
update 【可选】文章更新日期
tags 【可选】文章标签
categories 【可选】文章分类
keywords 【可选】文章关键词
description 【可选】文章描述
top_img 【可选】文章顶部图片
cover 【可选】文章缩略图(若果没有设置top_img,文章页顶部图片将显示缩略图,可设置为false/图片地址/留白
comments 【可选】显示文章评论模块
toc 【可选】显示文章toc,默认为设置中toc的enable配置
top_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,当设置mathjax的per_page:false时,才需要配置,默认false
aplayer 【可选】在需要的页面加载aplayer的css和js,请参考下面的音乐配置
highlight_sfrink 【可选】配置代码框是否展开(true或者false),默认设置为highlight_shrink的配置
aside 【可选】显示侧边栏,默认true
abcjs 【可选】加载abcjs。当设置abcjs的per_page为false时,才需要配置,默认false

2.3 标签页

  1. 进入hexo博客根目录
  2. 执行 hexo new page tags
  3. 会生成 source/tags/index.mg
  4. 在文件中添加 type: "tags"
1
2
3
4
5
6
7
---
title: 標籤
date: 2018-01-05 00:00:00
type: "tags"
orderby: random
order: 1
---
关键词 解释
type 【必须】页面类型,必须为tags
orderby 【可选】排序方式,可选值:random/name/length
order 【可选】排序次序,可选值:1,asc for ascending;-1,desc fordescending

2.4 分类页

  1. 进入hexo博客根目录
  2. 执行 hexo new page categories
  3. 会生成 source/tags/index.mg
  4. 在文件中添加 type: "categories"
1
2
3
4
5
---
title: 分類
date: 2018-01-05 00:00:00
type: "categories"
---

2.5 友情链接

  1. 进入hexo博客根目录
  2. 执行 hexo new page link
  3. 会生成 source/tags/index.mg
  4. 在文件中添加 type: "link"
1
2
3
4
5
---
title: 友情鏈接
date: 2018-06-07 22:17:49
type: "link"
---

友情链接的排序,只需要在顶部的front-matter中添加 random: true

友情链接添加分为两种方式:

  • 本地生成
    在hexo博客目录的source/_data(如果没有可以创建)文件下,创建名字为link.yml的文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- class_name: 友情鏈接
class_desc: 那些人,那些事
link_list:
- name: Hexo
link: https://hexo.io/zh-tw/
avatar: https://d33wubrfki0l68.cloudfront.net/6657ba50e702d84afb32fe846bed54fba1a77add/827ae/logo.svg
descr: 快速、簡單且強大的網誌框架

- class_name: 網站
class_desc: 值得推薦的網站
link_list:
- name: Youtube
link: https://www.youtube.com/
avatar: https://i.loli.net/2020/05/14/9ZkGg8v3azHJfM1.png
descr: 視頻網站
- name: Weibo
link: https://www.weibo.com/
avatar: https://i.loli.net/2020/05/14/TLJBum386vcnI1P.png
descr: 中國最大社交分享平台
- name: Twitter
link: https://twitter.com/
avatar: https://i.loli.net/2020/05/14/5VyHPQqR6LWF39a.png
descr: 社交分享平台

class_name 和 class_desc支持HTML格式书写,若不需要可以留白。

  • 远程拉取

从4.0.0开始,支持远程加载友情链接数据,格式只支持json。
选择远程数据时,本地生成数据的方法会失效。
具体方法,在 source/link/index.md中添加远程链接。

1
flink_url: xxxxx

json数据格式举例如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[
{
"class_name": "友情鏈接",
"class_desc": "那些人,那些事",
"link_list": [
{
"name": "Hexo",
"link": "https://hexo.io/zh-tw/",
"avatar": "https://d33wubrfki0l68.cloudfront.net/6657ba50e702d84afb32fe846bed54fba1a77add/827ae/logo.svg",
"descr": "快速、簡單且強大的網誌框架"
}
]
},
{
"class_name": "網站",
"class_desc": "值得推薦的網站",
"link_list": [
{
"name": "Youtube",
"link": "https://www.youtube.com/",
"avatar": "https://i.loli.net/2020/05/14/9ZkGg8v3azHJfM1.png",
"descr": "視頻網站"
},
{
"name": "Weibo",
"link": "https://www.weibo.com/",
"avatar": "https://i.loli.net/2020/05/14/TLJBum386vcnI1P.png",
"descr": "中國最大社交分享平台"
},
{
"name": "Twitter",
"link": "https://twitter.com/",
"avatar": "https://i.loli.net/2020/05/14/5VyHPQqR6LWF39a.png",
"descr": "社交分享平台"
}
]
}
]

2.6 图库

图库只是普通页面,只需要 hexo new page xxxx 创建即可。
然后使用标签外挂galleryGroup,具体用法请查看对应内容。

1
2
3
4
5
<div class="gallery-group-main">
{% galleryGroup '壁紙' '收藏的一些壁紙' '/Gallery/wallpaper' https://i.loli.net/2019/11/10/T7Mu8Aod3egmC4Q.png %}
{% galleryGroup '漫威' '關於漫威的圖片' '/Gallery/marvel' https://i.loli.net/2019/12/25/8t97aVlp4hgyBGu.jpg %}
{% galleryGroup 'OH MY GIRL' '關於OH MY GIRL的圖片' '/Gallery/ohmygirl' https://i.loli.net/2019/12/25/hOqbQ3BIwa6KWpo.jpg %}
</div>

2.7 子页面

子页面也是普通页面,只需要 hexo new page xxxx创建即可。
然后使用标签外挂gallery,具体方法请查看具体内容。

1
2
3
4
5
6
7
8
9
10
11
{% gallery %}
![](https://i.loli.net/2019/12/25/Fze9jchtnyJXMHN.jpg)
![](https://i.loli.net/2019/12/25/ryLVePaqkYm4TEK.jpg)
![](https://i.loli.net/2019/12/25/gEy5Zc1Ai6VuO4N.jpg)
![](https://i.loli.net/2019/12/25/d6QHbytlSYO4FBG.jpg)
![](https://i.loli.net/2019/12/25/6nepIJ1xTgufatZ.jpg)
![](https://i.loli.net/2019/12/25/E7Jvr4eIPwUNmzq.jpg)
![](https://i.loli.net/2019/12/25/mh19anwBSWIkGlH.jpg)
![](https://i.loli.net/2019/12/25/2tu9JC8ewpBFagv.jpg)
{% endgallery %}

2.8 404页面

主题内置了一个404页面。

1
2
3
4
5
# A simple 404 page
error_404:
enable: true
subtitle: "頁面沒有找到"
background: