一、搭建hexo并部署到Github
1. 安装Git
下载地址:https://git-scm.com/downloads
全部选择默认选项安装即可。
安装完成后在开始菜单里找到“Git”,打开“Git Bash”。跳出窗口,说明Git安装成功
在窗口输入
1 2
| git config --global user.name "Your Name" git config --global user.email "[email protected]"
|
查看Git版本
git --verison
2. node下载和安装
下载地址:https://nodejs.cn/
直接安装
测试:
3. 安装hexo
创建Blog文件夹,存放博客文件,然后在文件夹下右键git bash打开。
npm安装hexo
输入hexo -v
验证是否安装成功
初始化hexo
本地预览
1 2
| hexo generate //生成静态网页,可简写 hexo g hexo server //打开本地服务器,可简写 hexo s
|
浏览器输入 http://localhost:4000/
4. 部署到Github
注册github账号,自行百度
打开 https://github.com/
,新建一个项目仓库,命名为:
1
| geek.github.io //用户名.github.ioo
|
创建ssh
id_rsa是主机的私人秘钥,不能泄漏。
id_rsa.pub是公共秘钥可以给他人看。
把公钥放在github上。
生成秘钥:
1
| ssh-keygen -t rsa -C "yourmail"
|
在主机用户目录里找到.ssh
目录,里面有id_rsa
和id_rsa.pub
两个文件。
打开github,在头像下面点击settings
,再点击SSH and GPG keys
,新建一个SSH
,名字随便去,把id_rsa.pub
里面的信息复制进去。
在git bash
输入ssh -T [email protected]
,出现下面的信息,以及出现用户名,就成功了
1 2
| $ ssh -T [email protected] Hi geek! You've successfully authenticated, but GitHub does not provide shell access.
|
修改hexo配置文件
打开博客根目录下的config.yml
文件
修改最后一行配置
1 2 3 4
| deploy: type: git repository: https://github.com/geek/geek/github.io.git branch: master
|
部署
需要先安装deploy-git
,也就是部署命令,才能用命令部署到github
1
| npm install hexo-deployer-git --save
|
然后hexo三步走
1 2 3
| hexo clean //清除之前生成的东西 hexo generate //生成静态文章 hexo deploy //部署文章
|
二、安装butterfly主题
1. 安装
打开hexo
根目录,右键打开git bash
窗口
1
| npm install hexo-theme-butterfly
|
升级方法
1
| npm update hexo-theme-butterfly
|
2. 应用主题
修改更目录下的_config.yml
,把主题修改为butterfly
3. 安装插件
如果没有pug以及stylus渲染器,安装:
1
| npm install hexo-renderer-pug hexo-renderer-stylus --save
|
4.配置建议
在 hexo
的根目录创建一个文件 _config.butterfly.yml
,并把主题目录的 _config.yml
內容复制到 _config.butterfly.yml
去。
注意:复制的是主题的 _config.yml
,而不是hexo
的 _config.yml
不要把主题目录的 _config.yml
删掉
以后只需要在 _config.butterfly.yml
进行配置就行。
hexo
会自动合并主题中 _config.yml
和 _config.butterfly.yml
里的配置,如果存在同名配置,会使用 _config.butterfly.yml
的配置,其有限度较高。
三、页面配置
1. Page Front-matter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| --- title: date: updated: type: comments: description: keywords: top_img: mathjax: katex: aside: aplayer: highlight_shrink: random: limit: type: value: ---
|
参数 |
解释 |
title |
【必须】页面标题 |
type |
【必须】标签、分类、友情链接三个页面需要配置 |
updated |
【可选】页面更新日期 |
description |
【可选】页面描述 |
keywords |
【可选】页面关键字 |
comments |
【可选】展示页面评论模块(默认为true) |
top_img |
【可选】页面顶部图片 |
mathjax |
【可选】显示mathjax(当设置mathjax的per_page:false时,才需要配置,默认false) |
katex |
【可选】显示katex(当设置katex的per_page:false时,下需要配置,默认false) |
aside |
【可选】显示侧边栏(默认true) |
aplayer |
【可选】在需要的页面加载aplayer的js和css |
highlight_shrink |
【可选】配置代码框是否展开(true/false)(默认为设置中highlight_shrink的配置) |
random |
【可选】配置友情链接是否随机排序(默认为false) |
limit |
【可选】配置说说显示数量 |
limit.type |
【可选】配置说说显示数量的类型(date或者num) |
limit.value |
【可选】配置说说显示数量的值 |
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 27
| --- 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: noticeOutdate: ---
|
参数 |
解释 |
title |
【必须】文章标题 |
date |
【必须】文章创建日期 |
updated |
【可选】文章更新日期 |
tags |
【可选】文章标签 |
categories |
【可选】文章分类 |
keywords |
【可选】文章关键字 |
description |
【可选】文章描述 |
top_img |
【可选】文章顶部图片 |
cover |
【可选】文章缩略图(如果没有设置 top_img ,文章页顶部将显示缩略图,可设为 false/图片地址/留空) |
comments |
【可选】显示文章评论模块(默认 true ) |
toc |
【可选】显示文章 TOC(默认为设置中 enable 设置) |
toc_number |
【可选】显示 toc_number(默认为设置中 toc 的 number 配置) |
toc_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(当设置katex 的 per_page:false 时,才需要配置,默认 false ) |
aplayer |
【可选】在需要的页面加载 aplayer 的 js 和 css |
highlight_shrink |
【可选】配置代码框是否展开(true/false)(默认为设置中 highlight_shrink 的配置) |
aside |
【可选】显示侧边栏(默认true) |
abcjs |
【可选】加载 abcjs (当设置 abcjs 的 per_page:false 时,才需要配置,默认false ) |
noticeOutdate |
【可选】文章过期提醒(默认为设置中 noticeOutdate 的 enable 配置) |
3. 标签页
前往 Hexo 的根目录
打开git bash
,输入
找到 source/tags/index.md
文件
修改这个文件
1 2 3 4 5 6 7
| --- title: 標籤 date: 2025-02-05 00:00:00 type: 'tags' top_img: rgb(143,178,201) aside: false ---
|
4. 分类页
前往 Hexo 的根目录
打开 git bash
,输入
1
| hexo new page categories
|
找到 source/categories/index.md
文件
修改这个文件
1 2 3 4 5 6 7
| --- title: 分類 date: 2025-02-05 00:00:00 type: 'categories' top_img: rgb(143,178,201) aside: false ---
|
5. 友情链接
前往 Hexo 的根目录
打开 git bash
,输入
找到 source/link/index.md
文件
修改文件
1 2 3 4 5 6 7
| --- title: 友情鏈接 date: 2025-02-02 00:00:00 type: 'link' top_img: rgb(143,178,201) aside: false ---
|
数据来源
在 Hexo 根目录中的 source/_data
(如果没有 _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: 社交分享平台
|
友情链接界面可以由用户自己自定义,只需要在友情链接 Markdown 档设置就行,以普通的 Markdown 格式书写。
6. 404页面
主题内置了一个简单的404页面,可在设置中开启
本地预览时,访问出错的网站时不会跳到404页面的。
如需本地预览,请访问 http://localhost:4000/404.html
1 2 3 4 5
| error_404: enable: true subtitle: '頁面沒有找到' background:
|
四、主题配置
1. 配置文件速读
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
|
nav: logo: display_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: owner: enable: true since: 2019 custom_text: copyright: 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:
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:
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:
|
2. 语言
修改 Hexo 的配置文件 _config.yml
默认语言是 en
支持:
- default
- zh-CN(简体中文)
- zh-TW(台湾繁体中文)
- zh-HK(香港繁体中文)
- ja(日语)
- ko(韩语)
3. 目录
1 2 3 4 5 6 7
| 主页: / || fas fa-home 文章: /archives/ || fas fa-archive 标签: /tags/ || fas fa-tags 分类: /categories/ || fas fa-folder-open 链接||fas fa-list: 友情链接: /link/ || fas fa-link 关于: /about/ || fas fa-heart
|
4. 代码高度限制
配置代码高度限制,超出的部分会隐藏,并显示展开按钮。
1 2
| highlight_height_limit: 300
|
直接添加数字,不用加单位px
不适用于隐藏后的代码块( css 设置 display:none)
5. 社交图标
butterfly 支持 font-awesome v6 图标
书写格式 图标名:url || 描述性文字 || color
1 2 3
| social: fab fa-github: https://github.com/xxxxx || Github || "#hdhfbb" fas fa-envelope: mailto:[email protected] || Email || "#000000"
|
6. 图片设置
6.1 头像
1 2 3
| avatar: img: /img/avatar.png effect: true
|
6.2 顶部图
如果不显示顶部图,直接配置 disable_top_img: true
top_img: false
6.3 页脚背景图
6.4 网站背景
默认显示白色,可设置图片或者颜色
7. 文章封面
因博客可能只有博主自己看,考虑加载速度,所以关闭封面
1 2 3 4 5 6
| cover: # 是否显示文章封面 index_enable: false aside_enable: false archives_enable: false default_cover:
|
显示文章的相关信息的
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
|
9. 首页
9.1 首页顶部图大小
默认显示全屏,网站信息会剧中显示
1 2 3 4 5
|
index_site_info_top: index_top_img_height:
|
9.2 网站副标题
设置主页中显示的网站副标题或喜欢的座右铭。
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
|
10. 文章页
10.1 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 |
是否显示滚动进度百分比 |
10.2 文章版权
为博客文章展示文章版权和协议
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/
|
11. 搜索
1 2 3 4 5
| search: use: algolia_serch placeholder: 请输入需要搜索的内容
|
1 2 3 4
| algolia_search: hitsPerPage: 6
|
12. Inject
1 2 3 4 5
| inject: head: - <link rel="stylesheet" href="/self.css"> bottom: - <script src="xxxx"></script>
|
五、标签外挂
1. 选项卡(Tabs)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| {% tabs 样例 %}
<!-- tab 代码 -->
这里是代码
<!-- endtab -->
<!-- tab 预览 -->
这里是预览
<!-- endtab -->
{% endtabs %}
|
六、个人自定义
1. 页脚设置
css文件
在 source/css
目录下,新建 custom.css
文件
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
| #ft { max-width: 1200px; margin: 0 auto 12px; display: flex; color: rgb(255, 255, 255) !important; text-align: left; flex-wrap: wrap; }
.ft-item-1, .ft-item-2 { display: flex; height: 100%; padding: 10px 14px; }
.ft-item-1 { flex-direction: column; flex: 2; }
.ft-item-2 { flex: 1; flex-direction: column; }
.t-top { display: flex; }
.t-top .t-t-l { display: flex; flex-direction: column; flex: 1.4; margin-right: 10px; }
.t-top .t-t-l .bg-ad { width: 85%; border-radius: 10px; padding: 0 10px; }
.btn-xz-box { margin-top: 10px; background-color: #8e8d8f; }
.btn-xz { display: block; background-color: #8e8d8f; color: var(--btn-color); text-align: center; line-height: 2.4; margin: 8px 0; cursor: pointer !important; }
.btn-xz:hover { text-decoration: none !important;
}
.btn-xz-box:hover .btn-xz { background-color: #6595f0; }
.t-top .t-t-r { display: flex; flex-direction: column; flex: 1; }
.ft-links { padding: 0 14px; list-style: none; margin-top: 0 !important; }
.ft-links li a { display: inline-block !important; width: 50%; cursor: pointer !important; color: rgb(255, 255, 255) !important; }
.ft-links li a:hover { text-decoration: none !important; color: #6595f0 !important; }
.ft-item-2 .ft-img-group { width: 100%; }
.ft-t { font-size: 0.8rem; margin-bottom: 20px; line-height: 1; font-weight: 600; }
.t-l-t { padding-left: 14px; }
.ft-item-2 .ft-img-group .img-group-item { display: inline-block; width: 18.4%; margin-right: 14px; margin-bottom: 6px; }
.ft-item-2 .ft-img-group .img-group-item a { display: inline-block; width: 100%; height: 100%; cursor: pointer !important; }
.ft-item-2 .ft-img-group .img-group-item a img { width: 100%; max-height: 80px; }
@media screen and (max-width: 768px) {
.ft-item-1 { flex-basis: 100% !important; }
.ft-item-2 { flex-basis: 100% !important; }
.t-top .t-t-l .bg-ad { width: 100%; } }
@media screen and (max-width: 576px) { .t-top { flex-wrap: wrap; }
.t-top .t-t-l { flex-basis: 100% !important;
}
.t-top .t-t-r { margin-top: 16px; flex-basis: 100% !important; } }
|
进hexo中butterfly主题目录下,node_modules/hexo-theme-butterfly/layout/includes/footer.pug
更改文件内容
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
| #footer-wrap #ft .ft-item-1 .t-top .t-t-l p.ft-t.t-l-t 严肃声明 .bg-ad div | 请不要利用博客内的知识去做违法乱纪之事,任何利用博客去做违法犯罪的人和事,均与博主无关。该博客只为技术分享,一切皆为技术服务。 .btn-xz-box a.btn-xz(href='https://XXXX.com/') 跳转主页 .t-t-r p.ft-t.t-l-t 基础导航 ul.ft-links li a(href='https://XXXX.com/articles/hexo1600/') 建站指南 a(href='https://XXXX.com/nav.html') 网址导航 li a(href='https://XXXX.com/about/') 关于博主 a(href='https://XXXX.com/archives/') 文章归档 li a(href='https://XXXX.com/categories/') 文章分类 a(href='https://XXXX.com/tags/') 文章标签 .ft-item-2 p.ft-t.t-l-t 推荐链接 ul.ft-links li a(href='https://XXXX.com/') blog a(href='https://github.com/') github li a(href='https://bilibili.com/') bilibili a(href='https://leetcode.cn/') leetcode if theme.footer.owner.enable - var now = new Date() - var nowYear = now.getFullYear() if theme.footer.owner.since && theme.footer.owner.since != nowYear .copyright!= `©${theme.footer.owner.since} - ${nowYear + ' '} <i id="heartbeat" class="fa fas fa-heartbeat"></i> ${config.author}` else .copyright!= `©${nowYear + ' '} <i id="heartbeat" class="fa fas fa-heartbeat"></i> ${config.author}` if theme.footer.copyright .framework-info span= _p('footer.framework') + ' ' a(href='https://hexo.io')= 'Hexo' span.footer-separator | span= _p('footer.theme') + ' ' a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly' if theme.footer.custom_text .footer_custom_text!=`${theme.footer.custom_text}`
|
2. 黑夜模式
更改黑夜模式中页脚背景。
在 source/css/
目录下,新建 dartheme_modify.css
1 2 3 4 5 6 7 8 9 10 11 12 13
| [data-theme='dark'] #footer { background-color: rgb(26,26,26)!important; background-size: cover; }
@media (max-width: 768px) { [data-theme='dark'] #footer { background: rgb(26,26,26); background-size: cover; } }
|
3. 源文件备份
如果版本大于3.X,使用下面命令安装
1
| npm install hexo-git-backup --save
|
备份更新:
1 2
| npm remove hexo-git-backup npm install hexo-git-backup --save
|
安装完毕后,在 _config.yml
文件中配置:
1 2 3 4 5 6
| backup: type: git theme: butterfly message: MyBlog Buckup repository: github: [email protected]:xxx/xxx.git,branchName
|
注:theme为主题,message可以随便写,branchName为分支名