惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
H
Help Net Security
Last Week in AI
Last Week in AI
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
B
Blog
C
Check Point Blog
T
Tailwind CSS Blog
云风的 BLOG
云风的 BLOG
D
Docker
Recent Announcements
Recent Announcements
Vercel News
Vercel News
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
月光博客
月光博客
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
The Register - Security
The Register - Security
V
Visual Studio Blog
F
Full Disclosure
Hugging Face - Blog
Hugging Face - Blog
T
Threat Research - Cisco Blogs
Latest news
Latest news
PCI Perspectives
PCI Perspectives
Cisco Talos Blog
Cisco Talos Blog
博客园 - Franky
D
DataBreaches.Net
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
P
Palo Alto Networks Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
T
Tenable Blog
L
LINUX DO - 热门话题
Spread Privacy
Spread Privacy

Butterfly

Butterfly 5.6 更新日誌 香港銀行開戶推薦 (附邀請碼) Butterfly 5.5 更新日誌 Butterfly 5.4 更新日誌 Butterfly 5.3 更新日誌 Butterfly 5.2 更新日誌 Butterfly 5.1 更新日誌 Butterfly 5.0 更新日誌 Butterfly 4.13 更新日誌 Butterfly 4.12 更新日誌 Butterfly 4.11 更新日誌 Butterfly 4.10 更新日誌 自定義側邊欄 當設置 top_img 為 false 時 Butterfly添加全局吸底Aplayer教程 自定義代碼配色 Butterfly 打賞 Butterfly 更新日誌 Butterfly 文檔(六) 進階教程 Butterfly 文檔(五) 主題問答 Butterfly 文檔(四) 標簽外挂 Butterfly 文檔(二) 主題頁面 Butterfly 文檔(一) 快速開始 沒有封面 標籤外掛(Tag Plugins) Markdown Style test
Butterfly 文檔(三) 主題配置
Jerry · 2020-05-28 · via Butterfly

配置文件速讀

你可以快速瞭解到所有配置的註解,讓你配置文件更加方便。
如果遇到不太清楚的配置,可以在這篇文章找到更加詳細的資訊。

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245




nav:

logo:

display_title: true

display_post_title: true

fixed: false

menu:









code_blocks:

theme: light

macStyle: false

height_limit: false

word_wrap: false



copy: true

language: true

shrink: false

fullpage: false




social:






favicon: /img/favicon.png


avatar:

img: https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png

effect: false


disable_top_img: false


default_top_img:


index_img:


archive_img:


tag_img:




tag_per_img:


category_img:




category_per_img:


footer_img: false




background:


cover:

index_enable: true
aside_enable: true
archives_enable: true


position: both

default_cover:



error_img:

flink: /img/friend_404.gif

post_page: /img/404.jpg


error_404:

enable: false

subtitle: 'Page Not Found'

background: https://i.loli.net/2020/05/19/aKOcLiyPl2JQdFD.png


post_meta:

page:

date_type: created

date_format: date

categories: true

tags: false

label: true

post:

position: left

date_type: both

date_format: date

categories: true

tags: true

label: true








index_site_info_top:

index_top_img_height:


subtitle:

enable: false

effect: true


typed_option:







source: false

sub:




index_layout: 1






index_post_content:
method: 3

length: 500





toc:

post: true

page: false

number: true

expand: false

style_simple: false

scroll_percent: true

post_copyright:

enable: true

decode: false

author_href:

license: CC BY-NC-SA 4.0

license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/


reward:

enable: false

text:
QR_code:









post_edit:

enable: false


url:


related_post:

enable: true

limit: 6

date_type: created





post_pagination: 1


noticeOutdate:

enable: false

style: flat

limit_day: 365

position: top
message_prev: 已經過了
message_next: 天自上次更新,文章內容可能已過時。




footer:

nav:
owner:

enable: true

since: 2019

custom_text:

copyright:
enable: true

version: true





aside:

enable: true

hide: false

button: true

mobile: true

position: right
display:

archive: true

tag: true

category: true
card_author:

enable: true

description:
button:

enable: true

icon: fab fa-github

text: Follow Me

link: https://github.com/xxxxxx
card_announcement:

enable: true

content: This is my Blog
card_recent_post:

enable: true

limit: 5

sort: date
sort_order:
card_newest_comments:

enable: false
sort_order:

limit: 6

storage: 10

avatar: true
card_categories:

enable: true

limit: 8

expand: none
sort_order:
card_tags:

enable: true

limit: 40

color: false

orderby: random

order: 1
sort_order:
card_archives:

enable: true

type: monthly

format: MMMM YYYY

order: -1

limit: 8
sort_order:
card_post_series:

enable: true

series_title: false

orderBy: 'date'

order: -1
card_webinfo:

enable: true

post_count: true

last_push_date: true
sort_order:



runtime_date:






rightside_bottom:


translate:

enable: false

default:

defaultEncoding: 2

translateDelay: 0

msgToTraditionalChinese: '繁'

msgToSimplifiedChinese: '簡'


readmode: true


darkmode:

enable: true

button: true




autoChangeMode: false

start:
end:


rightside_scroll_percent: false




rightside_item_order:

enable: false

hide:

show:


rightside_config_animation: true






anchor:

auto_update: false

click_to_scroll: false


photofigcaption: false


copy:

enable: true

copyright:
enable: false

limit_count: 150


wordcount:

enable: false

post_wordcount: true

min2read: true

total_wordcount: true


busuanzi:

site_uv: true

site_pv: true

page_pv: true








math:


use:
per_page: true
hide_scrollbar: false

mathjax:

enableMenu: true

tags: none

katex:

copy_tex: false





search:


use:
placeholder:


algolia_search:

hitsPerPage: 6


local_search:

preload: false

top_n_per_article: 1

unescape: false
CDN:



docsearch:
appId:
apiKey:
indexName:
option:





share:


use: sharejs



sharejs:
sites: facebook,twitter,wechat,weibo,qq



addtoany:
item: facebook,twitter,wechat,sina_weibo,facebook_messenger,email,copy_link





comments:




use:

text: true


lazyload: false

count: false

card_post_count: false



disqus:

shortname:

apikey:



disqusjs:

shortname:

apikey:

option:



livere:

uid:



gitalk:

client_id:

client_secret:

repo:

owner:

admin:

option:



valine:

appId:

appKey:

avatar: monsterid

serverURLs:

bg:

visitor: false

option:



waline:

serverURL:

bg:

pageview: false

option:



utterances:

repo:

issue_term: pathname

light_theme: github-light

dark_theme: photon-dark



facebook_comments:

app_id:

user_id:

pageSize: 10

order_by: social

lang: zh_TW



twikoo:

envId:

region:

visitor: false

option:



giscus:

repo:

repo_id:

category_id:

theme:
light: light
dark: dark

option:



remark42:

host:

siteId:

option:



artalk:

server:

site:

visitor: false

option:





chat:

use:

rightside_button: false

button_hide_show: false



chatra:

id:



tidio:

public_key:



crisp:

website_id:







baidu_analytics:



google_analytics:



cloudflare_analytics:



microsoft_clarity:


umami_analytics:
enable: false

serverURL:
website_id:
option:
UV_PV:
site_uv: false
site_pv: false
page_pv: false

token:


google_tag_manager:
tag_id:

domain:






google_adsense:

enable: false

auto_ads: true

js: https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

client:

enable_page_level_ads: true


ad:

index:

aside:

post:





site_verification:



















































category_ui:
tag_ui:


text_align_justify: false


mask:
header: true
footer: true


preloader:

enable: false



source: 1

pace_css_url:


enter_transitions: true


display_mode: light


beautify:

enable: false

field: post

title-prefix-icon:

title-prefix-icon-color:



font:
global-font-size:
code-font-size:
font-family:
code-font-family:


blog_title_font:
font_link:
font-family:


hr_icon:

enable: true

icon:
icon-top:



activate_power_mode:

enable: false

colorful: true

shake: true

mobile: false






canvas_ribbon:

enable: false

size: 150

alpha: 0.6
zIndex: -1

click_to_change: false

mobile: false


canvas_fluttering_ribbon:

enable: false

mobile: false



canvas_nest:

enable: false

color: '0,0,255'

opacity: 0.7

zIndex: -1

count: 99

mobile: false


fireworks:

enable: false
zIndex: 9999

mobile: false


click_heart:

enable: false

mobile: false


clickShowText:

enable: false
text:



fontSize: 15px

random: false

mobile: false









lightbox:






series:

enable: false

orderBy: 'title'

order: 1

number: true



abcjs:

enable: false

per_page: true



mermaid:

enable: false

code_write: false

theme:
light: default
dark: dark



chartjs:
enable: false



fontColor:
light: "rgba(0, 0, 0, 0.8)"
dark: "rgba(255, 255, 255, 0.8)"

borderColor:
light: "rgba(0, 0, 0, 0.1)"
dark: "rgba(255, 255, 255, 0.2)"

scale_ticks_backdropColor:
light: "transparent"
dark: "transparent"


note:





style: flat

icons: true

border_radius: 3


light_bg_offset: 0






pjax:

enable: false

exclude:



aplayerInject:

enable: false

per_page: true




snackbar:

enable: false

position: bottom-left

bg_light: '#49b1f5'
bg_dark: '#1f1f1f'



instantpage: false



lazyload:

enable: false

native: false

field: site
placeholder:
blur: false




pwa:

enable: false

manifest:

apple_touch_icon:

favicon_32_32:

favicon_16_16:

mask_icon:



Open_Graph_meta:

enable: true
option:










structured_data: true



css_prefix: true



inject:
head:

bottom:




CDN:




internal_provider: local
third_party_provider: jsdelivr


version: false



custom_format:

option:

語言

修改 Hexo 的配置文件 _config.yml

默認語言是 en

主題支持

  • default(en)
  • zh-CN (簡體中文)
  • zh-TW (臺灣繁體中文)
  • zh-HK (香港繁體中文)
  • ja (日語)
  • ko (韓語)

網站資料

修改網站各種資料,例如標題、副標題和郵箱等個人資料,請修改 Hexo 的_config.yml

butterfly-docs-hexo-config.png

導航

參數設置

1
2
3
4
5
6
7
nav:

logo: /xxxx.png
display_title: true
display_post_title: true

fixed: false
參數解釋
logo網站的 logo,支持圖片,直接填入圖片鏈接
display_title是否顯示網站標題,填寫 true 或者 false
display_post_title是否在滾動時顯示文章標題,填寫 true 或者 false
fixed是否固定狀態欄,填寫 true 或者 false

目錄

1
2
3
4
5
6
7
8
9
Home: / || fas fa-home
Archives: /archives/ || fas fa-archive
Tags: /tags/ || fas fa-tags
Categories: /categories/ || fas fa-folder-open
List||fas fa-list:
Music: /music/ || fas fa-music
Movie: /movies/ || fas fa-video
Link: /link/ || fas fa-link
About: /about/ || fas fa-heart

必須是 /xxx/,後面||分開,然後寫圖標名。

如果不希望顯示圖標,圖標名可不寫。

默認子目錄是展開的,如果你想要隱藏,在子目錄裡添加 hide

1
2
3
List||fas fa-list||hide:
Music: /music/ || fas fa-music
Movie: /movies/ || fas fa-video

注意: 導航的文字可自行更改

例如:

1
2
3
4
5
6
7
8
9
10
11
menu:
首頁: / || fas fa-home
時間軸: /archives/ || fas fa-archive
標籤: /tags/ || fas fa-tags
分類: /categories/ || fas fa-folder-open
清單||fa fa-heartbeat:
音樂: /music/ || fas fa-music
照片: /Gallery/ || fas fa-images
電影: /movies/ || fas fa-video
友鏈: /link/ || fas fa-link
關於: /about/ || fas fa-heart

hexo-theme-butterfly-doc-menu.png

代碼塊

代碼塊中的所有功能只適用於 Hexo 自帶的代碼渲染

如果使用第三方的渲染器,不一定會有效

1
2
3
4
5
6
7
8
9
10
11
12
13
14
code_blocks:

theme: light
macStyle: false

height_limit: false
word_wrap: false


copy: true
language: true

shrink: false
fullpage: false
參數解釋
theme代碼高亮主題,可選 darker / pale night / light / ocean / false
macStyle是否使用 Mac 風格
height_limit代碼塊高度限制(單位: px), 可填寫 數字 或者 false
word_wrap是否自動換行
copy是否顯示複製按鈕
language是否顯示語言標籤
shrinktrue: 收縮代碼塊 / false: 展開代碼塊 / none: 展開代碼塊並隱藏按鈕
fullpage是否全屏顯示代碼塊

代碼高亮主題

Butterfly 支持 6 種代碼高亮樣式:

  • darker
  • pale night
  • light
  • ocean

如果你需要 MacOS 風格的代碼高亮樣式,可以把macStyle 設為 true

主題從 3.0 開始,支持使用自定義的代碼顔色。

如何自定義主題,請查看下面這篇文章。

自定義代碼配色

代碼框展開/關閉

在默認情況下,代碼框自動展開,可設置是否所有代碼框都關閉狀態,點擊>可展開代碼

  • true 全部代碼框不展開,需點擊>打開
  • false 代碼框展開,有>點擊按鈕
  • none 不顯示>按鈕
1
highlight_shrink: true 

你也可以在 post/page 頁對應的 markdown 文件 front-matter 添加 highlight_shrink 來獨立配置。

主題配置文件中highlight_shrink 設為 true 時,可在 front-matter 添加highlight_shrink: false來單獨配置文章展開代碼框。

主題配置文件中highlight_shrink 設為 false 時,可在 front-matter 添加highlight_shrink: true來單獨配置文章收縮代碼框。

highlight_shrink: true

hexo-theme-butterfly-doc-highlight-shrink-true.png

highlight_shrink: false

hexo-theme-butterfly-doc-highlight-shrink-false.png

highlight_shrink: none

hexo-theme-butterfly-docs-highlight-shirk-none.png

代碼換行

在默認情況下,Hexo 在編譯的時候不會實現代碼自動換行。如果你不希望在代碼塊的區域裡有橫向滾動條的話,那麼你可以考慮開啟這個功能。

1
code_word_wrap: true

如果你是使用 highlight 渲染,需要找到你站點的 Hexo 配置文件_config.yml,將line_number改成false:

1
2
3
4
5
highlight:
enable: true
line_number: false
auto_detect: false
tab_replace:

如果你是使用 prismjs 渲染,需要找到你站點的 Hexo 配置文件_config.yml,將line_number改成false:

1
2
3
4
5
prismjs:
enable: false
preprocess: true
line_number: false
tab_replace: ''

hexo-theme-butterfly-doc-code-word-wrap-before.png

hexo-theme-butterfly-doc-code-word-wrap-after.png

代碼高度限制

可配置代碼高度限制,超出的部分會隱藏,並顯示展開按鈕。

1
highlight_height_limit: false 

注意:

  1. 單位是 px,直接添加數字,如 200

  2. 實際限制高度為 highlight_height_limit + 30 px ,多增加 30px 限制,目的是避免代碼高度只超出 highlight_height_limit 一點時,出現展開按鈕,展開沒內容。

  3. 不適用於隱藏後的代碼塊( css 設置 display: none)

社交圖標

Butterfly 支持 font-awesome v6 圖標.

書寫格式 圖標名:url || 描述性文字 || color

1
2
3
social:
fab fa-github: https://github.com/xxxxx || Github || "#hdhfbb"
fas fa-envelope: mailto:xxxxxx@gmail.com || Email || "#000000"

圖標名可在這尋找

hexo-theme-butterfly-doc-fontawesome.png

PC:

!hexo-theme-butterfly-doc-fontawesome.png

Mobile:

hexo-theme-butterfly-doc-socila-icon-mobile.png

圖片設置

頭像

1
2
3
avatar:
img: /img/avatar.png
effect: true

hexo-theme-butterfly-doc-avatar.png

頂部圖

如果不要顯示頂部圖,可直接配置 disable_top_img: true

頂部圖的獲取順序,如果都沒有配置,則不顯示頂部圖。

  1. 頁面頂部圖的獲取順序:

    各自配置的 top_img > 配置文件的 default_top_img

  2. 文章頁頂部圖的獲取順序:

    各自配置的 top_img > cover > 配置文件的 default_top_img

配置中的值:

配置解釋
index_img主頁的 top_img
default_top_img默認的 top_img,當頁面的 top_img 沒有配置時,會顯示 default_top_img
archive_img歸檔頁面的 top_img
tag_imgtag 子頁面 的 默認 top_img
tag_per_imgtag 子頁面的 top_img,可配置每個 tag 的 top_img
category_imgcategory 子頁面 的 默認 top_img
category_per_imgcategory 子頁面的 top_img,可配置每個 category 的 top_img

其它頁面 (tags/categories/自建頁面)和 文章頁 的 top_img ,請到對應的 md 頁面設置front-matter中的top_img

以上所有的 top_img 可配置以下值

配置的值效果
留空顯示默認的 top_img(如有),否則顯示默認的顔色
(文章頁 top_img 留空的話,會顯示 cover 的值)
img 鏈接圖片的鏈接,顯示所配置的圖片
顔色(
HEX 值 - #0000FF
RGB 值 - rgb(0,0,255)
顔色單詞 - orange
漸變色 - linear-gradient( 135deg, #E2B0FF 10%, #9F44D3 100%)
對應的顔色
transparent透明
false不顯示 top_img

tag_per_imgcategory_per_img 是 3.2.0 新增的內容,可對 tag 和 category 進行單獨的配置

並不推薦為每個 tag 和每個 category 都配置不同的頂部圖,因為配置太多會拖慢生成速度

1
2
3
4
5
6
7
tag_per_img:
aplayer: https://xxxxxx.png
android: ddddddd.png

category_per_img:
隨想: hdhdh.png
推薦: ddjdjdjd.png

theme-butterfly-docs-page-top-img-false.png

theme-butterfly-docs-post-top-img-false-new.png

theme-butterfly-docs-top-img-orange.png

top_img: 'linear-gradient(20deg, #0062be, #925696, #cc426e, #fb0347)'

theme-butterfly-docs-top-img-color.png

頁腳背景圖

1
2

footer_img: true
配置的值效果
留空/false顯示默認的顔色
img 鏈接圖片的鏈接,顯示所配置的圖片
顔色(
HEX 值 - #0000FF
RGB 值 - rgb(0,0,255)
顔色單詞 - orange
漸變色 - linear-gradient( 135deg, #E2B0FF 10%, #9F44D3 100%)
對應的顔色
transparent透明
true顯示跟 top_img 一樣

網站背景

默認顯示白色,可設置圖片或者顏色

1
2
3


background:

留意: 如果你的網站根目錄不是'/',使用本地圖片時,需加上你的根目錄。
例如:網站是 https://yoursite.com/blog,引用一張img/xx.png圖片,則設置 background 為 /blog/img/xx.png

hexo-theme-butterfly-doc-set-body-background-color.png

hexo-theme-butterfly-doc-set-body-background-img.png

文章封面

文章的 markdown 文檔上,在 Front-matter 添加 cover ,並填上要顯示的圖片地址。

如果不配置 cover,可以設置顯示默認的 cover。

如果不想在首頁顯示 cover, 可以設置為 false

文章封面的獲取順序 Front-matter 的 cover > 配置文件的 default_cover > false

1
2
3
4
5
6
cover:

index_enable: true
aside_enable: true
archives_enable: true
default_cover:
參數解釋
index_enable主頁是否顯示文章封面圖
aside_enable側欄是否顯示文章封面圖
archives_enable歸檔頁面是否顯示文章封面圖
default_cover默認的 cover, 可配置圖片鏈接/顔色/漸變色等

當配置多張圖片時,會隨機選擇一張作為 cover.此時寫法應為

1
2
3
4
default_cover:
- https://jsd.012700.xyz/gh/jerryc127/CDN@latest/cover/default_bg.png
- https://jsd.012700.xyz/gh/jerryc127/CDN@latest/cover/default_bg2.png
- https://jsd.012700.xyz/gh/jerryc127/CDN@latest/cover/default_bg3.png

hexo-theme-butterfly-doc-post-cover.png

hexo-theme-butterfly-doc-post-cover-show.png

hexo-theme-butterfly-docs-cover-false.png

這個選項是用來顯示文章的相關信息的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
post_meta:

page:

date_type: created

date_format: date
categories: true
tags: false
label: true
post:

position: left

date_type: both

date_format: date
categories: true
tags: true
label: true

主頁:

參數解釋
date_type顯示文章的時間,可選 created / updated / both
date_format配置時間顯示明確時間還是相對時間,可選 date / relative
categories是否顯示文章的分類
tags是否顯示文章的標籤
label是否顯示文字標簽

文章頁:

參數解釋
position文章頁 meta 顯示的位置,可選 left / center
date_type顯示文章的時間,可選 created / updated / both
date_format配置時間顯示明確時間還是相對時間,可選 date / relative
categories是否顯示文章的分類
tags是否顯示文章的標籤
label是否顯示文字標簽

hexo-theme-butterfly-docs-page-meta.png

hexo-theme-butterfly-doc-post-info.png

hexo-theme-butterfly-doc-post-tag.png

date_format 是 3.2.0 新增的內容,配置時間顯示明確時間還是相對時間

theme-butterfly-docs-relative-time.png

theme-butterfly-docs-full-date.png

首頁

首頁頂部圖大小

默認的顯示為全屏,網站信息會居中顯示

1
2
3
4
5



index_site_info_top:
index_top_img_height:

注意:index_top_img_height的值不能使用百分比。
2 個都不填的話,會使用默認值

舉例,當

1
index_top_img_height: 400px

效果

hexo-theme-butterfly-doc-index-top-img-setting.png

網站副標題

可設置主頁中顯示的網站副標題或者喜歡的座右銘。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

subtitle:
enable: false

effect: true


typed_option:






source: false

sub:
- 今日事,今日畢
- Never put off till tomorrow what you can do today

hexo-theme-butterfly-doc-index-subtitle.gif

首頁卡片佈局

主題文章卡片支持 7 種佈局

1
index_layout: 3

配置解釋:

配置值解釋
1封面在左,信息在右
2封面在右,信息在左
3封面和信息左右交替顯示
4封面在上,信息在下
5信息顯示在封面上
6瀑布流佈局 - 封面在上,信息在下
7瀑布流佈局 - 信息顯示在封面上

填寫數字序號即可,默認為 3

主頁文章節選

因為主題 UI 的關係,主頁文章節選只支持自動節選文章頁description

1
2
3
4
5
6
7
8
9





index_post_content:
method: 3

length: 500
參數解釋
method顯示文章內容的方式,有四種可供選擇
1 - 只顯示 description
2 - 優先選擇 description,如果沒有配置 description,則顯示自動節選的內容
3 - 只顯示自動節選
4 - 不顯示文章內容
length自動節選的長度,只有在 method 為 2 或者 3 的時候才需要配置 length

description在 front-matter 裡添加

hexo-theme-butterfly-doc-post-description.png

文章頁

TOC 目錄

在側邊欄顯示 TOC(文章目錄)

1
2
3
4
5
6
7
8
toc:
post: true
page: false
number: true
expand: false

style_simple: false
scroll_percent: true
屬性解釋
post文章頁是否顯示 TOC
page普通頁面是否顯示 TOC
number是否顯示章節數
expand是否展開 TOC
style_simple簡潔模式(側邊欄顯示 TOC, 只對文章頁有效 )
scroll_percent是否顯示滾動進度百分比

為特定的文章配置

在你的文章md文件的頭部,加入toc_numbertoc,並配置true或者false即可。

主題會優先判斷文章 Markdown 的 Front-matter 是否有配置,如有,則以 Front-matter 的配置為準。否則,以主題配置文件中的配置為準。

文章版權

為你的博客文章展示文章版權和許可協議。

1
2
3
4
5
6
7
8
9
10
11
post_copyright:

enable: true

decode: false

author_href:

license: CC BY-NC-SA 4.0

license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/

由於Hexo 4.1開始,默認對網址進行解碼,以至於如果是中文網址,會被解碼,可設置decode: true來顯示中文網址。

如果有文章(例如:轉載文章)不需要顯示版權,可以在文章 Front-matter 單獨設置

1
copyright: false

3.0.0開始,支持對單獨文章設置版權信息,可以在文章 Front-matter 單獨設置

1
2
3
4
copyright_author: xxxx
copyright_author_href: https://xxxxxx.com
copyright_url: https://xxxxxx.com
copyright_info: 此文章版權歸 xxxxx 所有,如有轉載,請註明來自原作者

版權顯示截圖

文章打賞/贊助

在你每篇文章的結尾,可以添加贊助按鈕。相關二維碼可以自行配置。

對於沒有提供二維碼的,可配置一張軟件的 icon 圖片,然後在 link 上添加相應的贊助鏈接。用戶點擊圖片就會跳轉到鏈接去。

link 可以不寫,會默認為圖片的鏈接。

1
2
3
4
5
6
7
8
9
10
reward:
enable: true
text:
QR_code:
- img: /img/wechat.jpg
link:
text: 微信
- img: /img/alipay.jpg
link:
text: 支付寶

文章編輯按鈕

在文章標題旁邊顯示一個編輯按鈕,點擊會跳轉到對應的鏈接去。

1
2
3
4
5
6
7


post_edit:
enable: false


url:

hexo-theme-butterfly-docs-post-edit.png

hexo-theme-butterfly-docs-post-edit-2.png

相關文章

當文章封面設置為 false 時,或者沒有獲取到封面配置,相關文章背景將會顯示主題色。

相關文章推薦的原理是根據文章 tags 的比重來推薦

1
2
3
4
related_post:
enable: true
limit: 6
date_type: created

文章分頁按鈕

當文章封面設置為 false 時,或者沒有獲取到封面配置,分頁背景將會顯示主題色。

可設置分頁的邏輯,也可以關閉分頁顯示

1
2
3
4
5
6





post_pagination: false
參數解釋
post_pagination: false關閉分頁按鈕
post_pagination: 1下一篇顯示的是舊文章
post_pagination: 2下一篇顯示的是新文章

文章過期提醒

如果你想單獨關閉某些文章的過期提醒,你可以在對應文章頁的 front-matter 中配置 noticeOutdate: false 來關閉。

可設置是否顯示文章過期提醒,以更新時間為基準。

1
2
3
4
5
6
7
8
9
10
11

noticeOutdate:
enable: false

style: flat

limit_day: 365

position: top
message_prev: It has been
message_next: days since the last update, the content of the article may be outdated.
配置解釋
enable是否開啟文章過期提醒
style提醒樣式, simple / flat
limit_day設置多少天後提醒,默認 365 天
position提醒位置 top / bottom
message_prev提示文字
message_next提示文字

hexo-theme-butteffly-docs-outdate-flat.png

hexo-theme-butterfly-docs-outdated-simple.png

頁腳

頁腳導航欄

頁腳導航欄可以配置為顯示在頁腳的頂部,或者不顯示。

你可以配置或者留空
留空則顯示舊版頁腳

以下是示例:

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
42
43
nav:
- width:
content:
- title: 文檔
item:
- title: 🚀 快速開始
url: /posts/21cfbf15/
- title: 📑 主題頁面
url: /posts/dc584b87/
- title: 📌 主題配置
url: /posts/4aa8abbe/
- title: ⚔️ 標簽外掛
url: /posts/ceeb73f/
- title: 主題問答
url: /posts/98d20436/
- title: ⚡️ 進階教程
url: /posts/4073eda/
- content:
- title: 其他
item:
- title: 圖庫
url: /Gallery/
- title: 留言板
url: /messageboard/
- title: 說說
url: /talking/
- title: 示例
url: /link/
- title: 友鏈
url: /links/
- content:
- title: 框架
item:
- title: Hexo
url: https://hexo.io/zh-cn/
- title: Butterfly
url: https://butterfly.js.org/
- content:
- title: 贊助
item:
- title: 支付寶
url: https://jsd.012700.xyz/gh/jerryc127/CDN/Photo/alipay.jpg
html: "<img src='https://jsd.012700.xyz/gh/jerryc127/CDN/Photo/alipay.jpg' alt='JerryC' width='100px' height='100px'>"

配置解釋

配置解釋
width設置寬度,建議不配置(可不寫)
content頁腳導航欄的內容,支持多個內容,每個內容可以有多個項目
title頁腳導航欄的標題
item頁腳導航欄的項目,支持多個項目,每個項目可以有標題和鏈接
title頁腳導航欄項目的標題
url頁腳導航欄項目的鏈接
html頁腳導航欄項目的 HTML 內容,支持圖片等其他內容

博客年份

since是一個來展示你站點起始時間的選項。它位於頁面的最底部。

1
2
3
4
footer:
owner:
enable: true
since: 2018

hexo-theme-butterfly-doc-since.png

頁腳自定義文本

custom_text是一個給你用來在頁腳自定義文本的選項。通常你可以在這裡寫聲明文本等,支持 HTML。

1
custom_text: Hi, welcome to my <a href="https://butterfly.js.org/">blog</a>!

hexo-theme-butterfly-doc-footer-text.png

對於部分人需要寫 ICP 的,也可以寫在 custom_text

1
custom_text: <a href="icp鏈接"><img class="icp-icon" src="icp圖片"><span>備案號:xxxxxx</span></a>

Aside

配置

側邊欄的配置

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
aside:
enable: true
hide: false

button: true
mobile: true

position: right
display:
archive: true
tag: true
category: true
card_author:
enable: true
description:
button:
enable: true
icon: fab fa-github
text: Follow Me
link: https://github.com/xxxxxx
card_announcement:
enable: true
content: This is my Blog
card_recent_post:
enable: true

limit: 5

sort: date
sort_order:
card_newest_comments:
enable: false
sort_order:
limit: 6

storage: 10
avatar: true
card_categories:
enable: true

limit: 8

expand: none
sort_order:
card_tags:
enable: true

limit: 40
color: false

orderby: random

order: 1
sort_order:
card_archives:
enable: true

type: monthly

format: MMMM YYYY

order: -1

limit: 8
sort_order:
card_post_series:
enable: true

series_title: false

orderBy: 'date'

order: -1
card_webinfo:
enable: true
post_count: true
last_push_date: true
sort_order:



runtime_date:

sort_order 是給每個卡片配置的排序,如果不配置,則按照主題配置文件的排序。數字越小,越靠前。

配置解釋
enable是否啟用側邊欄
hide是否默認隱藏側邊欄
button是否顯示隱藏側邊欄的按鈕
mobile是否在移動端顯示側邊欄
position側邊欄位置,left / right
display.archivearchive 頁面是否顯示 aside
display.tagtag 頁面是否顯示 aside
display.categorycategory 頁面是否顯示 aside
card_author.enable是否顯示作者卡片
card_author.description作者描述信息
card_author.button.enable是否顯示按鈕
card_author.button.icon按鈕圖標,可在這裡找到圖標名稱:https://fontawesome.com/icons?d=gallery&m=free
card_author.button.text按鈕文字
card_author.button.link按鈕鏈接
card_announcement.enable是否顯示公告卡片
card_announcement.content公告內容 (可使用 html 標簽)
card_recent_post.enable是否顯示最新文章卡片
card_recent_post.limit顯示文章數目,0 為全部
card_recent_post.sort排序方式,date / updated
card_newest_comments.enable是否顯示最新評論卡片
card_newest_comments.limit顯示評論數目,0 為全部
card_newest_comments.storage保存時間,單位分鐘,保存到本地存儲,避免每次刷新都重新請求數據
card_newest_comments.avatar是否顯示頭像
card_categories.enable是否顯示分類卡片
card_categories.limit顯示分類數目,0 為全部
card_categories.expand是否展開分類,none / true / false
card_tags.enable是否顯示標籤卡片
card_tags.limit顯示標籤數目,0 為全部
card_tags.color是否顯示標籤顔色
card_tags.orderby標籤排序方式,random / name / length
card_tags.order排序方式,1 為升序,-1 為降序
card_archives.enable是否顯示歸檔卡片
card_archives.type歸檔類型,monthly / yearly
card_archives.format歸檔顯示格式,例如:YYYY 年 MM 月
card_archives.order排序方式,1 為升序,-1 為降序
card_archives.limit顯示歸檔數目,0 為全部
card_post_series.enable是否顯示文章系列卡片
card_post_series.series_title是否顯示系列名稱
card_post_series.orderBy排序方式,title / date
card_post_series.order排序方式,1 為升序,-1 為降序
card_webinfo.enable是否顯示網站信息卡片
card_webinfo.post_count是否顯示文章數量
card_webinfo.last_push_date是否顯示最後更新日期
card_webinfo.runtime_date顯示網站運行時間,不需要開啟,留空白就行(開啟格式一定要是 Month/Day/Year Time 或者 Year/Month/Day Time

目前有三個評論 Livere、Facebook Comments 和 Giscus 不支持最新評論。

最新評論只會在刷新時才會去讀取,並不會實時變化

由於 API 有 訪問次數限制,為了避免調用太多,主題默認存取期限為 10 分鐘。也就是説,調用後資料會存在 localStorage 裡,10 分鐘內刷新網站只會去 localStorage 讀取資料。 10 分鐘期限一過,刷新頁面時才會去調取 API 讀取新的數據。( 3.6.0 新增了 storage 配置,可自行配置緩存時間)

butterfly-docs-card-tags-color-false.png

butterfly-docs-card-tags-color-true.png

hexo-theme-butterfly-doc-runtime.png

自定義添加欄目

點擊前往

右下角按鈕

按鈕位置

當開啟 chat 聊天服務後,聊天服務的按鈕可能會遮擋到右下角的按鈕,可以設置按鈕的位置。
非必要不建議設置,默認就行

1
2

rightside_bottom:

默認單位為 px,直接添加數字即可。

簡繁轉換

主題內置了一個簡單的簡繁轉換功能,採用一對一的形式配對。遇到一字多繁或者一字多簡的情況下,會出現不能正常轉換正確的簡繁體,請留意。

開啟後,右下角會有簡繁轉換按鈕。

1
2
3
4
5
6
7
8
9
10
11
12
translate:
enable: true

default:

defaultEncoding: 1

translateDelay: 0

msgToTraditionalChinese: '繁'

msgToSimplifiedChinese: '簡'

閲讀模式

閲讀模式下會去掉除文章外的內容,避免幹擾閲讀。

只會出現在文章頁面,右下角會有閲讀模式按鈕。

1
readmode: true

夜間模式

右下角會有夜間模式按鈕

1
2
3
4
5
6
7
8
9

darkmode:
enable: true

button: true
autoChangeMode: false

start:
end:
參數解釋
button是否在右下角顯示日夜模式切換按鈕
autoChangeMode自動切換的模式
autoChangeMode: 1 跟隨系統而變化,不支持的瀏覽器/系統將按照時間 start 到 end 之間切換為 light mode
autoChangeMode: 2 只按照時間 start 到 end 之間切換為 light mode ,其餘時間為 dark mode
autoChangeMode: false 取消自動切換
startlight mode 的開始時間
endlight mode 的結束時間

hexo-theme-butterfly-doc-dark-mode-1.png

滾動狀態百分比

1
2

rightside_scroll_percent: true

按鈕排序

可對右下角按鈕進行排序

注意: 不要重複

1
2
3
4
5
6
7



rightside_item_order:
enable: false
hide:
show:

全局配置

頁面錨點

開啟頁面錨點後,當你在進行滾動時,頁面鏈接會根據標題 ID 進行替換
(注意: 每替換一次,會留下一個歷史記錄。所以如果一篇文章有很多錨點的話,網頁的歷史記錄會很多。)

1
2
3
4
5
6

anchor:

auto_update: false

click_to_scroll: false
配置解釋
auto_update當滾動時,URL 將根據標題 id 更新。默認為 false
click_to_scroll點擊標題滾動並更新錨點。默認為 false

圖片描述

可開啟圖片 Figcaption 描述文字顯示

優先顯示圖片的 title 屬性,然後是 alt 屬性

1
photofigcaption: true

複製相關配置

可配置網站是否可以複製、複製的內容是否添加版權信息

1
2
3
4
5
6
copy:
enable: true

copyright:
enable: false
limit_count: 150
配置解釋
enable是否開啟網站複製權限
copyright複製的內容後面加上版權信息
enable是否開啟複製版權信息添加
limit_count字數限制,當複製文字大於這個字數限制時,將在複製的內容後面加上版權信息
1
2
3
4
5
6
7
Lorem ipsum dolor sit amet, test link consectetur adipiscing elit. Strong text pellentesque ligula commodo viverra vehicula. Italic text at ullamcorper enim. Morbi a euismod nibh. Underline text non elit nisl. Deleted text tristique, sem id condimentum tempus, metus lectus venenatis mauris, sit amet semper lorem felis a eros. Fusce egestas nibh at sagittis auctor. Sed ultricies ac arcu quis molestie. Donec dapibus nunc in nibh egestas, vitae volutpat sem iaculis. Curabitur sem tellus, elementum nec quam id, fermentum laoreet mi. Ut mollis ullamcorper turpis, vitae facilisis velit ultricies sit amet. Etiam laoreet dui odio, id tempus justo tincidunt id. Phasellus scelerisque nunc sed nunc ultricies accumsan.


作者: Jerry
連結: http://localhost:4000/posts/bd3c650b/#Paragraph
來源: Butterfly
著作權歸作者所有。商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。

字數統計

開啟字數統計功能,需要安裝hexo-wordcount插件

在 hexo 工作目錄下運行 npm install hexo-wordcount --save or yarn add hexo-wordcount

1
2
3
4
5
6
7
8
9

wordcount:
enable: false

post_wordcount: true

min2read: true

total_wordcount: true
參數解釋
post_wordcount在文章頁面顯示字數
min2read在文章頁面顯示閲讀時間
total_wordcount在側邊欄顯示網站總字數

hexo-theme-butterfly-doc-word-count.png

hexo-theme-butterfly-docs-wordcount-totalcount.png

訪問人數 busuanzi (UV 和 PV)

訪問 busuanzi 的官方網站查看更多的介紹。

由於 busuanzi 的穩定性問題,偶爾會遇到無法訪問的情況,請留意。

文章頁的訪問人數統計,是通過 busuanzi 這個插件實現的。個別評論系統自帶訪問人數統計功能,可以在相對應的評論系統配置中進行開啟,其會代替 busuanzi 的統計。

1
2
3
4
busuanzi:
site_uv: true
site_pv: true
page_pv: true

如果需要修改 busuanzi 的 CDN 鏈接,可通過 主題配置文件CDN 中的 option 進行修改

1
2
3
CDN:
option:
busuanzi: xxxxxxxxx

hexo-theme-butterfly-doc-busuanzi-site-pv.png

hexo-theme-butterfly-doc-pv.png

Math 數學

主題支持兩種數學公式渲染引擎,MathJaxKaTeX。你可以根據自己的需求選擇一種。

1
2
3
4
5
6
7
8
9



math:


use:
per_page: true
hide_scrollbar: false
參數解釋
use選擇數學公式渲染引擎,選擇 mathjaxkatex,如果不需要數學公式,請留空
per_page是否每一頁都加載數學公式渲染引擎,如果設置為 false,則需要在文章的 Front-matter 添加 mathjax: truekatex: true,對應的文章才會加載數學公式渲染引擎
hide_scrollbar是否隱藏滾動條

不要在標題裡使用 mathjax 語法,toc 目錄不一定能正確顯示 mathjax,可能顯示 mathjax 代碼

建議使用 KaTex 獲得更好的效果,下文有介紹!

開啟 Mathjax 需要把 use 設置為 mathjax

mathjax 配置文件

1
2
3
4
5
mathjax:

enableMenu: true

tags: none
參數解釋
enableMenu啟用右鍵菜單
tags選擇是否編號,all 全部編號,ams 只編號公式,none 不編號

使用 Mathjax 前,你需要卸載 hexo 的 markdown 渲染器,然後安裝hexo-renderer-kramed

以下操作在你 hexo 博客的目錄下 (不是 Butterfly 的目錄):

  1. 安裝插件

    1
    2
    npm uninstall hexo-renderer-marked --save
    npm install hexo-renderer-kramed --save
  2. 配置 hexo 根目錄的配置文件

    1
    2
    3
    4
    5
    6
    7
    8
    kramed:
    gfm: true
    pedantic: false
    sanitize: false
    tables: true
    breaks: true
    smartLists: true
    smartypants: true

效果:

hexo-theme-butterfly-doc-mathjax-2.jpg

不要在標題裡使用 KaTeX 語法,toc 目錄不能正確顯示 KaTeX。

開啟 KaTeX 需要把 use 設置為 katex

1
2
3
katex:

copy_tex: false
參數解釋
copy_tex啟用複製 KaTeX 公式功能

你不需要添加 katex.min.js 來渲染數學方程。相應的你需要卸載你之前的 hexo 的 markdown 渲染器,然後安裝其它插件。

因為 KaTeX 更快更輕量,因此沒有 MathJax 的功能多(比如右鍵菜單)。為那些使用 MathJax 的用戶,主題也內置了 katex 的 複製 功能。

hexo-theme-butterfly-doc-katex.gif

搜索

主題支持三種搜索方式(algolia_search / local_search / docsearch),你可以選擇一種或者多種搜索方式。

1
2
3
4
5
search:


use:
placeholder:
參數解釋
use選擇你需要的搜索方式,不需要開啟留空白
placeholder搜索框的提示文字

記得運行 hexo clean

  1. 你需要安裝 hexo-algoliahexo-algoliasearch. 根據它們的説明文檔去做相應的配置。

  2. 把主題配置文件中 search 的 use 配置為 algolia_search

其它配置

1
2
3
4

algolia_search:

hitsPerPage: 6
參數解釋
hitsPerPage每頁顯示的搜索結果數量
  1. 運行 Hexo

記得運行 hexo clean

  1. 你需要安裝 hexo-generator-searchdb 或者 hexo-generator-search,根據它的文檔去做相應配置

  2. 把主題配置文件中 search 的 use 配置為 local_search

其它配置

1
2
3
4
5
6
7
8
9

local_search:

preload: false

top_n_per_article: 1

unescape: false
CDN:
參數解釋
preload預加載,開啟後,進入網頁後會自動加載搜索文件。關閉時,只有點擊搜索按鈕後,才會加載搜索文件
top_n_per_article匹配的文章結果,默認顯示最開始的 1 段結果
unescape將 html 字符串解碼為可讀字符串
CDN搜索文件的 CDN 地址(默認使用的本地鏈接)

DocSearch 是另一款由 algolia 提供的搜索服務,具體申請和使用請查看 DocSearch 文檔

  1. 你需要申請 DocSearch,並獲取你的 appId, apiKey, indexName
  2. 把主題配置文件中 search 的 use 配置為 docsearch

其它配置

1
2
3
4
5
6
7
# Docsearch
# https://docsearch.algolia.com/
docsearch:
appId:
apiKey:
indexName:
option:
參數解釋
appId【必須】你的 Algolia 應用 ID
apiKey【必須】你的 Algolia 搜索 API key
indexName【必須】你的 Algolia index name
option【可選】其餘的 docsearch 配置
具體配置可查這裡

hexo-theme-butterfly-docs-docsearch.png

分享

只能選擇一個分享服務商

主題支持兩種分享方式,一種是sharejs,一種是addtoany

1
2
3
4
share:


use: sharejs
參數解釋
use選擇分享方式,可選sharejsaddtoany,如果不需要分享請留空

如果你不知道 sharejs,看看它的説明。

1
2
3
4


sharejs:
sites: facebook,twitter,wechat,weibo,qq

hexo-theme-butterfly-doc-sharejs.png

可以到addtoany查看使用説明

1
2
addtoany:
item: facebook,twitter,wechat,sina_weibo,facebook_messenger,email,copy_link

hexo-theme-butterfly-doc-addtoany.png

評論

主題支持多種評論系統,你可以根據自己的喜好選擇一種。
你也可以選擇雙評論,只需要配置兩個評論(第一個為默認顯示)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
comments:




use:

text: true


lazyload: false

count: false

card_post_count: false
參數解釋
use使用的評論(請注意,最多支持兩個,如果不需要請留空)
注意:雙評論不能是 Disqus 和 Disqusjs 一起,由於其共用同一個 ID,會出錯
text是否顯示評論服務商的名字
lazyload是否為評論開啟 lazyload,開啟後,只有滾動到評論位置時才會加載評論所需要的資源(開啟 lazyload 後,評論數將不顯示
count是否在文章頂部顯示評論數
livere、Giscus 和 utterances 不支持評論數顯示
card_post_count是否在首頁文章卡片顯示評論數
gitalk、livere 、Giscus 和 utterances 不支持評論數顯示

註冊 disqus,配置你自己的 disqus,然後在Butterfly裡開啟它。

1
2
disqus:
shortname:
參數解釋
shortname你的 Disqus 短名稱,你可以在這裡創建

與 Disqus 一樣,但由於 Disqus 在中國大陸無法訪問, 使用 Disqusjs 可以在無法訪問 Disqus 時顯示評論。具體可參考Disqusjs

1
2
3
4
disqusjs:
shortname:
apikey:
option:
參數解釋
shortname你的 Disqus 短名稱,你可以在這裡創建
apikey你的 Disqus API Key,你可以在這裡創建
option可選配置

註冊來必力,配置你自己的來必力設置,然後在Butterfly裡開啟它。

1
2
livere:
uid:
參數解釋
uid你的來必力 uid,你可以在這裡創建

livere 的 uid 你能在這裡找到:

hexo-theme-butterfly-doc-laibili.jpg

遵循 gitalk的指示去獲取你的 github Oauth 應用的 client id 和 secret 值。以及查看它的相關配置説明。

1
2
3
4
5
6
7
gitalk:
client_id:
client_secret:
repo:
owner:
admin:
option:
參數解釋
client_idGitHub 應用的 client ID
client_secretGitHub 應用的 client secret
repo存儲 issues 的 repo
owner存儲 issues 的 repo 的擁有者
adminGitHub repository 的所有者和合作者 (對這個 repository 有寫權限的用戶)
option可選配置

遵循 Valine的指示去配置你的 LeanCloud 應用。以及查看相應的配置説明。

1
2
3
4
5
6
7
8
9
10
valine:
appId:
appKey:
avatar: monsterid

serverURLs:
bg:

visitor: false
option:
參數解釋
appIdLeanCloud 應用的 appId
appKeyLeanCloud 應用的 appKey
avatar頭像類型,可選值:''mpidenticonmonsteridwavatarretrorobohashblank404
serverURLs自定義 LeanCloud 服務器地址,如果你使用國內自定義域名,請填寫此項,否則無需填寫
bg背景圖片,可填寫圖片地址,如https://example.com/bg.jpg
visitor是否顯示文章閲讀數
option可選配置

開啟 visitor 後,文章頁的訪問人數將改為 Valine 提供,而不是 不蒜子

Valine 於 v1.4.5 開始支持自定義表情,如果你需要自行配置,請在emojiCDN配置表情 CDN。

同時在 Hexo 工作目錄下的source/_data/創建一個 json 文件valine.json,等同於 Valine 需要配置的emojiMapsvaline.json配置方式可參考如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"tv_doge": "6ea59c827c414b4a2955fe79e0f6fd3dcd515e24.png",
"tv_親親": "a8111ad55953ef5e3be3327ef94eb4a39d535d06.png",
"tv_偷笑": "bb690d4107620f1c15cff29509db529a73aee261.png",
"tv_再見": "180129b8ea851044ce71caf55cc8ce44bd4a4fc8.png",
"tv_冷漠": "b9cbc755c2b3ee43be07ca13de84e5b699a3f101.png",
"tv_發怒": "34ba3cd204d5b05fec70ce08fa9fa0dd612409ff.png",
"tv_發財": "34db290afd2963723c6eb3c4560667db7253a21a.png",
"tv_可愛": "9e55fd9b500ac4b96613539f1ce2f9499e314ed9.png",
"tv_吐血": "09dd16a7aa59b77baa1155d47484409624470c77.png",
"tv_呆": "fe1179ebaa191569b0d31cecafe7a2cd1c951c9d.png",
"tv_嘔吐": "9f996894a39e282ccf5e66856af49483f81870f3.png",
"tv_困": "241ee304e44c0af029adceb294399391e4737ef2.png",
"tv_壞笑": "1f0b87f731a671079842116e0991c91c2c88645a.png",
"tv_大佬": "093c1e2c490161aca397afc45573c877cdead616.png",
"tv_大哭": "23269aeb35f99daee28dda129676f6e9ea87934f.png",
"tv_委屈": "d04dba7b5465779e9755d2ab6f0a897b9b33bb77.png",
"tv_害羞": "a37683fb5642fa3ddfc7f4e5525fd13e42a2bdb1.png",
"tv_尷尬": "7cfa62dafc59798a3d3fb262d421eeeff166cfa4.png",
"tv_微笑": "70dc5c7b56f93eb61bddba11e28fb1d18fddcd4c.png",
"tv_思考": "90cf159733e558137ed20aa04d09964436f618a1.png",
"tv_驚嚇": "0d15c7e2ee58e935adc6a7193ee042388adc22af.png"
}

hexo-theme-butterfly-doc-valine.png

參數效果
留空(默認)
mp
identicon
monsterid
wavatar
retro
robohash
blank
404

Waline - 一款從 Valine 衍生的帶後端評論系統。可以將 Waline 等價成 With backend Valine。

具體配置可參考 waline 文檔

1
2
3
4
5
waline:
serverURL:
bg:
pageview: false
option:
參數解釋
serverURLWaline 服務器地址
bg背景圖片,可填寫圖片地址,如https://example.com/bg.jpg
pageview是否顯示文章閲讀數
option可選配置

開啟 pageview 後,文章頁的訪問人數將改為 Waline 提供,而不是 不蒜子

hexo-theme-butterfly-doc-valine.png

與 Gitalk 一樣,基於 GitHub issues 的評論工具。相對於 Gitalk,其相對需要權限較少。具體配置可參考Utterances

1
2
3
4
5
6
7
utterances:
repo:

issue_term: pathname

light_theme: github-light
dark_theme: photon-dark
參數解釋
repoGitHub repository 的全名,例如:owner/repo
issue_term用於識別問題的標籤,可以是 pathname/url/title/og:title
light_theme亮色主題,可選值:github-lightgithub-darkgithub-dark-orangeicy-darkdark-bluephoton-dark
dark_theme暗色主題,可選值:github-lightgithub-darkgithub-dark-orangeicy-darkdark-bluephoton-dark

hexo-theme-butterfly-docs-Utterances.png

Facebook Comments是 Facebook 提供的評論插件,需要登陸 Facebook 才可評論。

1
2
3
4
5
6
7
8
9
10


facebook_comments:
app_id:

user_id:
pageSize: 10

order_by: social
lang: zh_TW
參數解釋
app_idFacebook App ID,你可以在這裡創建
user_idFacebook User ID,可選,用於管理評論
pageSize顯示的評論數
order_by評論排序方式,social/time/reverse_time
lang語言

hexo-butterfly-docs-facebook-comments.png

Twikoo 是一個簡潔、安全、無後端的靜態網站評論系統,基於騰訊雲開發

具體如何配置評論,請查看 Twikoo 文檔

你只需要把獲取到的 環境ID (envId) 填寫到配置上去就行

1
2
3
4
5
twikoo:
envId:
region:
visitor: false
option:
參數解釋
envId環境 ID
region環境地域,默認為 ap-shanghai,如果您的環境地域不是上海,需傳此參數
visitor是否顯示文章閲讀數
option可選配置

開啟 visitor 後,文章頁的訪問人數將改為 Twikoo 提供,而不是 不蒜子

一個基於 GitHub Discussions 的評論

1
2
3
4
5
6
7
8
9
10


giscus:
repo:
repo_id:
category_id:
theme:
light: light
dark: dark
option:
參數解釋
repoGitHub repository 的全名,例如:owner/repo
repo_idGitHub repository 的 ID
category_idGitHub repository 的分類 ID
option可選配置

具體配置的意思,請參考 Giscus 的文檔

hexo-theme-butterfly-docs-giscus.png

Remark42 是一款只支持私有部署的評論

具體部署請查看 Installation | Remark42

1
2
3
4
remark42:
host:
siteId:
option:
參數解釋
host你的 Host URL
siteId你的 Site ID
option可選配置

Artalk 是一款只支持私有部署的評論

具體部署請查看 Artalk | 自託管評論系統

1
2
3
4
5
6
artalk:
server:
site:

visitor: false
option:
參數解釋
server你的 Server URL
site你的 Site ID
visitor是否顯示文章閲讀數
option可選配置

開啟 visitor 後,文章頁的訪問人數將改為 Artalk 提供,而不是 不蒜子

在綫聊天

主題內置了多種在綫聊天工具。你可以選擇開啟一種,方便你與訪客的交流。

1
2
3
4
5
6
7
8
9
chat:


use:


rightside_button: false

button_hide_show: false
參數解釋
use選擇你要使用的聊天工具,可選擇chatra/tidio/crisp
rightside_button是否開啟右下角聊天按鈕
button_hide_show是否開啟滾動時隱藏聊天按鈕

這些工具都提供了一個按鈕可以打開/關閉聊天窗口。
主題也提供了一個集合主題特色的按鈕來替換這些工具本身的按鈕,這個聊天按鈕將會出現在右下角裡。
你只需要把rightside_button打開就行。

為了不影響訪客的體驗,主題提供一個button_hide_show配置
設為true後,使用工具提供的按鈕時,只有向上滾動才會顯示聊天按鈕,向下滾動時會隱藏按鈕。

開啟 chatra, 把主題配置文件中 chatuse設置為chatra

配置 chatra,需要知道Public key

打開chatra並註冊賬號。
你可以在Preferences中找到Public key

hexo-theme-butterfly-docs-chat-chatra-id.png

1
2
3
4


chatra:
id: xxxxxxxx

chatra的樣式你可以Chat Widget自行配置

hexo-theme-butterfly-docs-chat-chatra-ui-settings.png

開啟 tidio, 把主題配置文件中 chatuse設置為tidio

配置 tidio,需要知道Public key

打開tidio並註冊賬號。
你可以在Preferences > Developer中找到Public key

hexo-theme-butterfly-docs-chat-tidio-id.png

1
2
3
4


tidio:
public_key: XXXX

tidio的樣式你可以Channels自行配置

hexo-theme-butterfly-docs-chat-tidio-setting.png

開啟 crisp, 把主題配置文件中 chatuse設置為crisp

打開crisp並註冊帳號

找到需要的網站 ID

1
2
3
4


crisp:
website_id: xxxxxxxx

hexo-theme-buttefly-docs-chat-crisp.png

hexo-theme-butterfly-docs-crisp-demo.png

分析統計

  1. 登錄百度統計的官方網站

  2. 找到你百度統計的統計代碼

hexo-theme-butterfly-doc-baidu-tongji.jpg

  1. 修改 主題配置文件
1
baidu_analytics: 你的代碼
  1. 登錄谷歌分析的官方網站

  2. 找到你的谷歌分析的跟蹤 ID

hexo-theme-butterfly-doc-google-analytics.jpg

  1. 修改 主題配置文件
1
google_analytics: 你的代碼 
  1. 登錄 Cloudflare 分析的官方網站
  2. 找到 JavaScript 程式碼片段
  3. 找到你的 token

hexo-theme-butterfly-docs-cloudflare-analytics-id.png

  1. 修改 主題配置文件

    1
    2
    3


    cloudflare_analytics:
  1. 登錄 Clarity 的官方網站

  2. 創建 PROJECT

  3. 找到你的 ID

hexo-theme-butterfly-docs-clarity-id.png

  1. 修改 主題配置文件

    1
    2
    3


    microsoft_clarity:

廣告

主題已集成谷歌廣告(自動廣告)

1
2
3
4
5
6
google_adsense:
enable: true
auto_ads: true
js: https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
client:
enable_page_level_ads: true

hexo-theme-butterfly-docs-google-adsense1.png

主題預留了三個位置可供插入廣告,分別為主頁文章(每三篇文章出現廣告)/aside 公告之後/文章頁打賞之後。
把 html 代碼填寫到對應的位置

1
2
3
4
ad:
index:
aside:
post:

例如:

1
index: <ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="xxxxxxxxxxxx" data-ad-client="ca-pub-xxxxxxxxxx" data-ad-slot="xxxxxxxxxx"></ins><script>(adsbygoogle=window.adsbygoogle||[]).push({})</script>

網站驗證

如果需要搜索引擎收錄網站,可能需要登錄對應搜索引擎的管理平臺進行提交。
各自的驗證碼可從各自管理平臺拿到

1
2
3
4
5
site_verification:




美化/特效

自定義主題色

可以修改大部分 UI 顏色

修改 主題配置文件,比如:

顏色值必須被雙引號包裹,就像"#000"而不是#000。否則將會在構建的時候報錯!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
theme_color:
enable: true
main: '#49B1F5'
paginator: '#00c4b6'
button_hover: '#FF7242'
text_selection: '#00c4b6'
link_color: '#99a9bf'
meta_color: '#858585'
hr_color: '#A4D8FA'
code_foreground: '#F47466'
code_background: 'rgba(27, 31, 35, .05)'
toc_color: '#00c4b6'
blockquote_padding_color: '#49b1f5'
blockquote_background_color: '#49b1f5'
scrollbar_color: '#49b1f5'
meta_theme_color_light: 'ffffff'
meta_theme_color_dark: '#0d0d0d'
參數解釋
main主題色
paginator分頁器顏色
button_hover按鈕 hover 顏色
text_selection文字選中顏色
link_color鏈接顏色
meta_color文章元數據顏色
hr_color分割線顏色
code_foreground代碼前景色
code_background代碼背景色
toc_color目錄顏色
blockquote_padding_color引用邊框顏色
blockquote_background_color引用背景色
scrollbar_color滾動條顏色
meta_theme_color_lightlight mode 主題色
meta_theme_color_darkdark mode 主題色

文字左右對齊

可設置文字向兩側對齊,對最後一行無效

1
2

text_align_justify: true

text_align_justify: false

黑色遮罩

為了避免圖片過於鮮艷而導致文字無法閲讀,默認為頂部圖頁腳添加黑色遮罩

1
2
3
4

mask:
header: true
footer: true

頁面加載動畫 preloader

當進入網頁時,因為加載速度的問題,可能會導致 top_img 圖片出現斷層顯示,或者網頁加載不全而出現等待時間,開啟 preloader 後,會顯示加載動畫,等頁面加載完,加載動畫會消失。

主題支持 pace.js 的加載動畫,具體可查看 pace.js

配置 butterly.yml

1
2
3
4
5
6
7
8
9

preloader:
enable: false



source: 1

pace_css_url:

hexo-theme-butterfly-docs-preloader.gif

頁面美化

會改變 ol、ul、h1-h5 的樣式

field配置生效的區域

  • post 只在文章頁生效
  • site 在全站生效
1
2
3
4
5
6

beautify:
enable: true
field: site
title-prefix-icon: '\f0c1'
title-prefix-icon-color: '#F47466'
參數解釋
enable是否開啟美化
field美化的區域
title-prefix-icon標題前綴的 icon
title-prefix-icon-color標題前綴的 icon 的顏色

title-prefix-icon填寫的是fontawesome的icon的Unicode數。
hexo-theme-butterfly-doc-fontwesome-unicode.png

hexo-theme-butterfly-doc-post-beautify.png

hexo-theme-butterfly-doc-post-beautif.png

自定義字體和字體大小

全局字體

可自行設置字體的font-family

如不需要配置,請留空

1
2
3
4
5
6
7


font:
global-font-size:
code-font-size:
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Lato, Roboto, "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", sans-serif
code-font-family: consolas, Menlo, "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", sans-serif
參數解釋
global-font-size全局字體大小
code-font-size代碼字體大小
font-family全局字體
code-font-family代碼字體

Blog 標題字體

可自行設置字體的font-family
如不需要配置,請留空。
如不需要使用網絡字體,只需要把 font_link 留空就行

1
2
3
4
5


blog_title_font:
font_link: https://fonts.googleapis.com/css?family=Titillium+Web&display=swap
font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft JhengHei', 'Microsoft YaHei', sans-serif
參數解釋
font_link網絡字體的連結
font-family網站標題字體

打字效果

打字效果activate-power-mode

1
2
3
4
5
6
7


activate_power_mode:
enable: true
colorful: true
shake: true
mobile: false
參數解釋
enable是否開啟打字效果
colorful是否開啟冒光特效
shake是否開啟抖動特效
mobile是否在移動端開啟打字效果

hexo-theme-butterfly-doc-type-animation.gif

背景特效

好看的綵帶背景,可設置每次刷新更換綵帶,或者每次點擊更換綵帶

1
2
3
4
5
6
7
8
9
canvas_ribbon:
enable: false

size: 150

alpha: 0.6
zIndex: -1
click_to_change: false
mobile: false
參數解釋
enable是否開啟綵帶特效
size綵帶的大小
alpha綵帶的透明度
zIndex綵帶的層級
click_to_change點擊更換綵帶
mobile手機端是否顯示綵帶

相關配置可查看canvas_ribbon

好看的綵帶背景,會飄動

1
2
3
canvas_fluttering_ribbon:
enable: true
mobile: false

1
2
3
4
5
6
7
8
9
10
11
canvas_nest:
enable: false

color: '0,0,255'

opacity: 0.7

zIndex: -1

count: 99
mobile: false
參數解釋
enable是否開啟綵帶特效
color綵帶的顏色
opacity綵帶的透明度
zIndex綵帶的層級
count綵帶的條數
mobile手機端是否顯示綵帶

鼠標點擊效果

1
2
3
4
fireworks:
enable: true
zIndex: 9999
mobile: false
參數解釋
enable是否開啟煙花特效
zIndex煙花的層級, -1 代表煙火效果在底部 /
9999 代表煙火效果在前面
mobile手機端是否顯示煙花

hexo-theme-butterfly-doc-firewall.gif

1
2
3
4

click_heart:
enable: true
mobile: false

click_heart.gif

1
2
3
4
5
6
7
8
9
10

ClickShowText:
enable: false
text:
- I
- LOVE
- YOU
fontSize: 15px
random: false
mobile: false
參數解釋
enable是否開啟文字特效
text文字內容
fontSize文字大小
random文字隨機顯示
mobile手機端是否顯示文字

ClickShowText.gif

圖片大圖查看模式

如果你並不想為某張圖片添加大圖查看模式,你可以使用 html 格式引用圖片,併為圖片添加 no-lightbox class 名

1
2
3
4
5




lightbox:

可配置 fancyboxmedium_zoom 來啟用圖片大圖查看模式
不需要大圖查看模式時,請留空

fancybox.gif

medium_zoom.gif

標簽外掛

具體可查看 標簽外掛

Mermaid

主題支持 Mermaid.js,可以在文章中使用 Mermaid.js 繪製流程圖、序列圖等。

配置:

1
2
3
4
5
6
7
8
9
10


mermaid:
enable: true

code_write: true

theme:
light: default
dark: dark

書寫方法

主題支持兩種書寫方法

標簽外掛

你可以使用標簽外掛的方式來使用 Mermaid.js
具體可查看 Mermaid 標簽外掛

代碼塊書寫

你可以使用代碼塊的方式來使用 Mermaid.js

  1. hexo 版本需要 7.0 或以上

  2. hexo 的配置文件 要添加 exclude_languages: ['mermaid']

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    syntax_highlighter: 'highlight.js'
    highlight:
    line_number: true
    auto_detect: false
    tab_replace: ''
    wrap: true
    hljs: false
    exclude_languages: ['mermaid']
    prismjs:
    preprocess: true
    line_number: true
    tab_replace: ''
    exclude_languages: ['mermaid']
  3. butterfly的配置文件中 mermaid 的 code_write 設為 true

例子

graph TD;
  A-->B;
  A-->C;
  B-->D;
  C-->D;

Pjax

當用戶點擊鏈接,通過 ajax 更新頁面需要變化的部分,然後使用 HTML5 的 pushState 修改瀏覽器的 URL 地址。

這樣可以不用重複加載相同的資源(css/js), 從而提升網頁的加載速度。

1
2
3
4
5
pjax:
enable: false

exclude:

對於一些第三方插件,有些並不支持 pjax 。
你可以把網頁加入到 exclude 裡,這個網頁會被 pjax 排除在外。
點擊該網頁會重新加載網站

使用 pjax 後,一些自己 DIY 的 js 可能會無效,跳轉頁面時需要重新調用,請參考Pjax 文檔
使用 pjax 後,一些個別頁面加載的 js/css,將會改為所有頁面都加載

Snackbar 彈窗

Snackbar 彈窗,根據自己愛好開啟

1
2
3
4
5
6
7
8
9




snackbar:
enable: true
position: bottom-left
bg_light: '#49b1f5'
bg_dark: '#2d3035'

Instantpage

當鼠標懸停到鏈接上超過 65 毫秒時,Instantpage 會對該鏈接進行預加載,可以提升訪問速度。

修改配置文件

1
2
3


instantpage: true

PWA

要為Butterfly配上 PWA 特性, 你需要如下幾個步驟:

  1. 打開 hexo 工作目錄

  2. npm install hexo-offline --save 或者 yarn add hexo-offline

  3. 在根目錄創建 hexo-offline.config.cjs 文件,並增加以下內容。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

module.exports = {
globPatterns: ['**/*.{js,html,css,png,jpg,gif,svg,webp,eot,ttf,woff,woff2}'],

globDirectory: 'public',
swDest: 'public/service-worker.js',
maximumFileSizeToCacheInBytes: 10485760,
skipWaiting: true,
clientsClaim: true,
runtimeCaching: [


{
urlPattern: /^https:\/\/cdn\.example\.com\/.*/,
handler: 'CacheFirst'
}
]
}

更多內容請查看 hexo-offline的官方文檔

  1. 主題配置文件中開啟 pwa 選項。
1
2
3
4
5
6
7
pwa:
enable: true
manifest: /img/pwa/manifest.json
apple_touch_icon: /img/pwa/apple-touch-icon.png
favicon_32_32: /img/pwa/32.png
favicon_16_16: /img/pwa/16.png
mask_icon: /img/pwa/safari-pinned-tab.svg
  1. 在創建source/目錄中創建manifest.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
40
41
42
43
44
45
46
47
{
"name": "string",
"short_name": "Junzhou",
"theme_color": "#49b1f5",
"background_color": "#49b1f5",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [
{
"src": "images/pwaicons/36.png",
"sizes": "36x36",
"type": "image/png"
},
{
"src": "images/pwaicons/48.png",
"sizes": "48x48",
"type": "image/png"
},
{
"src": "images/pwaicons/72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "images/pwaicons/96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "images/pwaicons/144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "images/pwaicons/192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/pwaicons/512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"splash_pages": null
}

你也可以通過 Web App Manifest快速創建manifest.json。(Web App Manifest 要求至少包含一個 512*512 像素的圖標)

  1. 可以通過Chrome插件Lighthouse檢查 PWA 配置是否生效以及配置是否正確。

    • 打開博客頁面
    • 啟動Lighthouse插件 (Lighthouse插件要求至少包含一個 512*512 像素的圖標)

關於 PWA(漸進式增強 Web 應用)的更多內容請參閲 Google Tools for Web Developers

Open Graph

head 裡增加一些 meta 資料,例如縮略圖、標題、時間等等。當你分享網頁到一些平臺時,平臺會讀取 Open Graph 的內容,展示縮略圖,標題等等信息。

修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12


Open_Graph_meta:
enable: true
option:







CSS 前綴

有些 CSS 並不是所有瀏覽器都支持,需要增加對應的前綴才會生效。

開啟 css_prefix 後,會自動為一些 CSS 增加前綴。(會增加 20%的體積)

修改配置文件

1
2

css_prefix: true

Inject

如想添加額外的 js/css/meta 等等東西,可以在 Inject 裡添加,支持添加到 head(</body>標籤之前)和 bottom(</html>標籤之前)。

請注意:以標準的 html 格式添加內容

例如

1
2
3
4
5
inject:
head:
- <link rel="stylesheet" href="/self.css">
bottom:
- <script src="xxxx"></script>

留意: 如果你的網站根目錄不是'/',使用本地圖片時,需加上你的根目錄。
例如:網站是 https://yoursite.com/blog,引用css/xx.css,則設置為<link rel="stylesheet" href="/blog/css/xx.css">

CDN

配置文件中最後一部分 CDN,裡面是主題所引用到的文件,可自行配置 CDN。(非必要請勿修改,配置後請確認鏈接是否能訪問)

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72


CDN:




internal_provider: local
third_party_provider: jsdelivr


version: false



custom_format:

option:






















































參數解釋
internal_provider主題內部文件
可選 local/jsdelivr/unpkg/cdnjs/custom
lcoal 為本地加載,custom 為自定義格式,需配置 custom_format
注意: 如果使用的是 Dev 版,只能設置為 local
third_party_provider第三方文件
可選 local/jsdelivr/unpkg/cdnjs/custom
lcoal 為本地加載,custom 為自定義格式,需配置 custom_format
注意: 如果你選擇 local 需要安裝 hexo-butterfly-extjs插件
versiontrue/false 為 cdn 加上指定版本號
custom_format自定義格式
option你可以在這裡更換部分文件,會覆蓋原有的配置

version

如需修改版本號,可修改主題目錄的 'plugins.yml' 中對應插件的 version

請確保你修改的版本號,你所使用的 cdn 有收錄

custom_format

提供以下參數

參數解釋
namenpm 上的包名
filenpm 上的文件路徑
min_filenpm 上的文件路徑(壓縮過的文件)
cdnjs_namecdnjs 上的包名
cdnjs_filecdnjs 上的文件路徑
min_cdnjs_filecdnjs 上的文件路徑(壓縮過的文件)
version插件版本號

部分可用的第三方 CDN 列表

請確保你選擇的 CDN 有收錄主題使用的第三方插件

提供商格式備註
Staticfile(七牛雲)https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file}同步 cdnjs
BootCDNhttps://cdn.bootcdn.net/ajax/libs/${cdnjs_name}/${version}/${min_cdnjs_file}同步 cdnjs
Elemecdn最新版本: https://npm.elemecdn.com/${name}@latest/${file}
指定版本: https://npm.elemecdn.com/${name}@${version}/${file}
同步 npm
⚔️ Butterfly-文檔-四-標簽外掛