Butterfly 2.3.5 优化
本片文章是根据 Buteeryfly 主题 2.3.5 版本修改。Butterfly 主题于 2020-6-16 更新至 3.0.0-RC-1 版本 (此版本为小更新)
2.3.5 版本涉及到修改源码,如果你要升级主题的话,你请看上方其他版本的优化教程。
如果你不想跟随下文一步步操作的话可以使用我优化好的:https://github.com/lete114/Hexo-themes-Butterfly-Lete
修改头部导航栏
修改前
1 |
|

修改后
1 |
|

添加搜索
在Butterfyl主题配置文件_config.yml文件中找到如下内容修改enable:为true
1 | local_search: |
作者Github:https://github.com/wzpan/hexo-generator-search
安装插件npm install hexo-generator-search --save
将搜索配置,添加到配置文件中,如下:
1 | # Local search |
效果图:

博客昵称颜色修改
C:\Hexo-Blog\themes\Butterfly\source\css\var.styl找到$light-grey = #EEEEEE
#EEEEEE修改为你喜欢的颜色
Lete乐特的颜色:#80bdab
效果图

如果你不想修改顶部导航栏颜色,就在C:\Hexo-Blog\themes\Butterfly\source\css\_layout\head.styl底部添加
1 | //头部颜色 |
效果图

移动端优化
C:\Hexo-Blog\themes\Butterfly\source\css\_third-party\normalize.min.css添加如下css代码:
1 | /*移动端优化:去除归档、标签、最新文章、公告、、只保留网站统计*/ |
去除前:

去除后:

背景图
横幅背景
1 | # if the banner of page not setting,it will show the top_img |
效果

博客背景
1 | # 设置网站背景 |
效果

页脚背景
打开C:\Hexo-Blog\themes\Butterfly\source\css\_layout\footer.styl文件把background: $light-blue注释掉即可
1 | #footer |
效果

页脚自定义
C:\Hexo-Blog\themes\Butterfly\layout\includes\footer.pug
修改前:
1 | #footer-wrap |

修改后:
1 | #footer-wrap |

页脚自定义内容
Butterfly主题配置文件_config.yml里找到footer_custom_text
1 | footer_custom_text: 我相信我可以,但我一直在路上,所以我有无限的可能!! |
效果图:

创建导航栏页面
关于我
1 | hexo new page about |
C:\Hexo-Blog\source\about\index.md
1 | --- |
分类
1 | hexo new page categories |
C:\Hexo-Blog\source\categories\index.md
1 | --- |
友情链接
1 | hexo new page link |
C:\Hexo-Blog\source\link\index.md
1 | --- |
C:\Hexo-Blog\source\目录下新建_data文件夹,文件夹内新建link.yml
1 | class: |
效果图

留言板
1 | hexo new page messageboard |
C:\Hexo-Blog\source\messageboard\index.md
1 | --- |
标签
1 | hexo new page tags |
C:\Hexo-Blog\source\tags\index.md
1 | --- |
主题颜色
默认主题颜色
1 | #### 美化/效果 #### |
其他
添加颜色块
C:\Hexo-Blog\themes\Butterfly\source\css\_third-party\normalize.min.css添加,当然你可以加更多颜色,这里我颜色3个色块
1 |
|
效果图
在Marcdown文件内容使用如下:
1 | --- |

鼠标样式
C:\Hexo-Blog\themes\Butterfly\source\css\_third-party\normalize.min.css添加如下css代码:
1 | /* 鼠标图标 */ |
文章透明
打开C:\Hexo-Blog\themes\Butterfly\source\css\_layout\page.styl找到如下代码
1 | .layout_post > #post, |
修改滚动条
打开C:\Hexo-Blog\themes\Butterfly\source\css\_global\var.styl找到如下代码:
1 | *::-webkit-scrollbar |
覆盖掉上面的代码👆
1 | /* 滚动条 */ |
修改前

修改后

添加樱花特效
把下方的内容添加到Butterfly主题下_config.yml文件的inject:下的bottom:里
1 | - <script src="https://cdn.jsdelivr.net/gh/lete114/CDN/Sum/sakura.js"></script>#樱花 |
效果图:

添加卖萌标题
把下方的内容添加到Butterfly主题下_config.yml文件的inject:下的bottom:里
1 | - <script src="https://cdn.jsdelivr.net/gh/lete114/CDN/Sum/title.js"></script>#樱花 |
效果图:


添加梨花带雨播放器
梨花带雨播放器:官网
播放器有两款样式,这里我选择的是第二种

复制代码添加到Butterfly主题下_config.yml文件的inject:下的bottom:里
效果图:

添加Aplayer音乐播放器
Aplayer音乐播放器:官网
打开C:\Hexo-Blog\themes\Butterfly\layout\includes\head.pug
尾部添加include ./third-party/aplayer.pug
C:\Hexo-Blog\themes\Butterfly\layout\includes\third-party文件夹内新建aplayer.pug内容图下:
1 | if theme.aplayer && theme.aplayer.enable |
Butterfly主题下_config.yml配置文件里添加
1 | ##侧边栏歌单 |
效果图:

2020-6-17
添加头部背景视频
提前说明:(其实也不会有人去看这个,不过我下面也提供了解决办法)

Video属性
| 属性 | 值 | 说明 |
|---|---|---|
| autoplay | autoplay | 如果出现该属性,则视频在就绪后马上播放。 |
| controls | controls | 如果出现该属性,则向用户显示控件,比如播放按钮。 |
| height | pixels | 设置视频播放器的高度。 |
| loop | loop | 如果出现该属性,则当媒介文件完成播放后再次开始播放。 |
| muted | muted | 规定视频的音频输出应该被静音。 |
| poster | URL | 规定视频下载时显示的图像,或者在用户点击播放按钮前显示的图像。 |
| preload | preload | 如果出现该属性,则视频在页面加载时进行加载,并预备播放。 如果使用 “autoplay”,则忽略该属性。 |
| src | url | 要播放的视频的 URL。 |
| width | pixels | 设置视频播放器的宽度。 |
新建
C:\Hexo-Blog\themes\Butterfly\source\js\video.js填入以下内容
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
40
41 /**
* Created by Lete on 2020/6/16.
*/
//判断移动端设备
browserRedirect();
function browserRedirect() {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {
var html = "<video loop autoplay style='height: 100%;width: 100%;object-fit: cover;'><source src='你的视频地址'></source></video>";
/*添加video*/
document.getElementById("nav").innerHTML += html;
/*打字效果*/
var subtitle = document.getElementById('subtitle')
var i = 0;
function typing() {
var timer = 0;
var str = '不要等到明天,今天就行动起来!!';
if (i <= str.length) {
subtitle.innerHTML = str.slice(0, i++)
timer = setTimeout(typing, 300)
} else {
subtitle.innerHTML = str
clearTimeout(timer)
}
}
typing()
}
}在
C:\Hexo-Blog\themes\Butterfly\_config.yml里找到inject:下的bottom:添加
1 - <script src="js/video.js"></script>
当然,你也可以使用gif动态图(这种方法最简单,Lete乐特使用的是视频)
在
C:\Hexo-Blog\themes\Butterfly\_config.yml里找到default_top_img:添gif图片参考Lete乐特:
1
2 # if the banner of page not setting,it will show the top_img
default_top_img: /img/a.gif
效果:
2020-6-19
添加UP酱
在C:\Hexo-Blog\themes\Butterfly\_config.yml里找到inject:下的bottom:引用
1 | <script src="https://cdn.jsdelivr.net/gh/lete114/CDN/js/upjiang.js"></script> |
效果图

添加公告栏装饰
在C:\Hexo-Blog\themes\Butterfly\_config.yml里找到card_announcement:下的content:后面添加

1 | <img src="https://cdn.jsdelivr.net/gh/lete114/CDN/Use/my_bg.gif"> |
效果图
