个性化主题 首先在~/Blog
的根目录中找到_config.yml
,然后在#Site
和#URL
中添加以下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 title: subtitle: description: keywords: author: language: timezone: url: permalink: :year/:month/:day/:title/ permalink_defaults: pretty_urls: trailing_index: true trailing_html: true
然后在~/Blog/themes
中找到现在使用的主题,例如Butterfly
,在Butterfly
的根目录中找到_config.yml
,对照Butterfly官方文档 进行个性化设置。 由于大陆互联网的特殊性,建议使用url的方式添加图片。
我的个性化设置 修改网站底部的页脚 我把网站底部的页脚footer修改成了这样: 其在themes\butterfly\source\css\_layout\footer.styl
的代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #footer position : relative background-color: transparent // 设置背景为透明 background-attachment: scroll background-position: bottom background-size: cover if hexo-config ('footer_img' ) != false && hexo-config ('mask.footer' ) &:before position: absolute width: 100% height: 100% background-color: rgba (255 , 255 , 255 , 0.5 ) // 设置半透明背景 backdrop-filter: blur (50px ) // 添加毛玻璃效果 content: ''
加入Latex数学公式 加入了对latex
数学公式的识别(参考文章 ),并设置为需要在文章的 Front-matter 添加mathjax: true
,对应的文章加载数学公式渲染引擎,latex效果如下:
加入字数统计和阅读时长统计 以及添加了字数统计和阅读时长统计,先安装hexo-wordcount
插件yarn add hexo-wordcount --save
,然后在~/Blog/theme/butterfly
下的_config.yml
中找到wordcount:
这一行,按照注释修改即可。
加入加载动画 加入加载动画,先在~/Blog/theme/butterfly/source/css
下创建flash.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 .pace { -webkit-pointer-events : none; pointer-events : none; -webkit-user-select : none; -moz-user-select : none; user-select : none; } .pace-inactive { display : none; } .pace .pace-progress { background : #29d ; position : fixed; z-index : 2000 ; top : 0 ; right : 100% ; width : 100% ; height : 2px ; } .pace .pace-progress-inner { display : block; position : absolute; right : 0px ; width : 100px ; height : 100% ; box-shadow : 0 0 10px #29d , 0 0 5px #29d ; opacity : 1.0 ; -webkit-transform : rotate (3deg ) translate (0px , -4px ); -moz-transform : rotate (3deg ) translate (0px , -4px ); -ms-transform : rotate (3deg ) translate (0px , -4px ); -o-transform : rotate (3deg ) translate (0px , -4px ); transform : rotate (3deg ) translate (0px , -4px ); } .pace .pace-activity { display : block; position : fixed; z-index : 2000 ; top : 15px ; right : 15px ; width : 14px ; height : 14px ; border : solid 2px transparent; border-top-color : #29d ; border-left-color : #29d ; border-radius : 10px ; -webkit-animation : pace-spinner 400ms linear infinite; -moz-animation : pace-spinner 400ms linear infinite; -ms-animation : pace-spinner 400ms linear infinite; -o-animation : pace-spinner 400ms linear infinite; animation : pace-spinner 400ms linear infinite; } @-webkit-keyframes pace-spinner { 0% { -webkit-transform : rotate (0deg ); transform : rotate (0deg ); } 100% { -webkit-transform : rotate (360deg ); transform : rotate (360deg ); } } @-moz-keyframes pace-spinner { 0% { -moz-transform : rotate (0deg ); transform : rotate (0deg ); } 100% { -moz-transform : rotate (360deg ); transform : rotate (360deg ); } } @-o-keyframes pace-spinner { 0% { -o-transform : rotate (0deg ); transform : rotate (0deg ); } 100% { -o-transform : rotate (360deg ); transform : rotate (360deg ); } } @-ms-keyframes pace-spinner { 0% { -ms-transform : rotate (0deg ); transform : rotate (0deg ); } 100% { -ms-transform : rotate (360deg ); transform : rotate (360deg ); } } @keyframes pace-spinner { 0% { transform : rotate (0deg ); transform : rotate (0deg ); } 100% { transform : rotate (360deg ); transform : rotate (360deg ); } }
然后在~/Blog/theme/butterfly
下的_config.yml
中找到preloader:
编辑如下:1 2 3 4 5 6 7 preloader: enable: true source: 2 pace_css_url: /css/flash.css
设置背景特效 在~/Blog/theme/butterfly
下的_config.yml
中找到canvas_nest:
编辑如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 canvas_nest: enable: true color: '240,240,240' opacity: 0.7 zIndex: -1 count: 150 mobile: false
效果如图:
一些小技巧 修改hexo
的_config.yml
文件后,可以输入hexo config test
来检查配置文件是否正确。以及输入hexo --debug
可以查看调试信息,方便排查问题。 还可以使用其他命令行参数来获取特定的调试信息。例如,hexo g --debug
(生成静态文件时显示调试信息)或 hexo s --debug
(启动服务器时显示调试信息)。 在hexo s
时可以修改目录下的配置文件,例如_config.yml
,source/_posts
等,来实时预览效果。