安装的插件:
☆RSS
npm install hexo-generator-feed --save
☆字数统计
☆next主题为5.x版本
安装 :npm install hexo-wordcount --save
然后在主题配置文件中启用
☆next主题为6.03+版本
安装:npm install hexo-symbols-count-time --save
打开 :~\blog_config.yml
添加
1 | symbols_count_time: |
然后在主题配置文件中启用
☆自定义站点内容搜索
安装 hexo-generator-searchdb,在站点的根目录下执行以下命令:
npm install hexo-generator-searchdb --save
编辑 站点配置文件,新增以下内容到任意位置:
search:
path: search.xml
field: post
format: html
limit: 10000
编辑 主题配置文件,启用本地搜索功能:
# Local search
local_search:
enable: true
☆链接持久化
npm install hexo-abbrlink --save
permalink: post/:abbrlink.html
permalink_defaults:
abbrlink:
alg: crc32 # 算法:crc16(default) and crc32
rep: hex # 进制:dec(default) and hex
☆修改标签云
1 | {{ tagcloud({min_font: 13, max_font: 31, amount: 1000, color: true, start_color: '#9733EE', end_color: '#FF512F'}) }} |
修改对应参数值即可,参数说明见 Hexo 官方文档,颜色可以参考这个网站,自己去纠结……
☆末尾版权信息
hexo next自带版权开启
1 | #Declare license on posts |
配置文件路径:\hexo\themes\next\layout_macro\post-copyright.swig
1 | +{% if page.copyright %} |
布局文件路径:\hexo\themes\next\layout_macro\post.swig
☆侧栏加入已运行的时间
我们都有自己的生日,都知道自己的岁数,那为什么不给博客加上,让读者知道博客的年纪呢?操作很简单,而且不是精确到年而是精确到秒,233333~
首先要加入下面代码:
1 | <div id="days"></div> |
上面Date的值记得改为你自己的,且按上面格式,然后修改:
1 | {# Blogroll #} |
这样就可以了!当然,要是不喜欢颜色,感觉不好看,就可以在上文所提的custom.styl
加入:
1 | // 自定义的侧栏时间样式 |
☆修改页面宽度
打开 \themes\next\source\css_variables\custom.styl
添加
1 | $main-desktop = 1200px |
以上适用于(NexT5.x版本),6.0+应该写
1 | $content-desktop-large = 830px |
☆修改模板文件(增加div,布局调整,避免互相影响)
~\blog\themes\next\layout_macro\post.swig
1 | - <div class="post-block"> |
~\blog\themes\next\layout_macro\post-collapse.swig
1 | {% macro render(post) %} |
☆评分上面加文字
~/blog/themes/next/layout/_macro/post.swig
1 | {% if theme.rating.enable %} |
然后 Ctrl + F 搜索rating,找到这段,对比我给出的,在绿色这行所示的位置,加上自己想要的说明和样式即可。
☆压缩文件
gulp.js 是基于流的自动化构建工具,我们可以使用 Gulp 为 Hexo 压缩文件
首先任意目录全局安装:
1 | npm install gulp -g |
然后到站点文件夹根目录:
1 | npm install gulp-minify-css --save |
打开 \blog\
新建 gulpfile.js
写入
1 | var gulp = require('gulp'); |
☆文末结束标记
打开 \themes\next\layout_macro\
新建 passage-end-tag.swig
写入
1 | {% if theme.passage_end_tag.enabled %} |
打开 \themes\next\layout_macro\post.swig
查找 wechat
添加,如下内容
1 | {#####################} |
打开 \themes\next_config.yml
添加
1 |
|
☆Live2d看板娘
live2d官方文档
安装 npm install --save hexo-helper-live2d
下载模型包:live2d-widget-models
解压
将packages
中的文件放到node_modules
中
打开 ~\blog_config.yml
添加
1 | live2d: |
☆引入自定义文件(用于样式定制)
打开 \themes\next\layout_custom\
新建 custom.swig
打开 \themes\next\layout_layout.swig
在 </body> 前添加
1 | {% include '_custom/custom.swig' %} |
☆评论输入打字礼花及震动特效
下载 activate-power-mode.js
放置 activate-power-mode.js 至 CDN
打开 \themes\next\layout_custom\custom.swig
添加
1 | <!-- 打字礼花及震动特效 --> |
☆添加emoji
参考自 :emoji插件
☆站点地图生成
安装
1 | npm install hexo-generator-sitemap --save |
在站点配置文件中启用
1 | # 自动生成sitemap |
☆文章加密码
☆方式一:修改模板配置文件(不推荐)
打开 ~\blog\themes\next6.4\layout_partials\head\
新建 password.swig
写入
1 |
|
然后打开~\blog\themes\next6.4\layout_partials\head\head.swig
写入
1 | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/> |
最后 在需要加密的文章前面增加属性 password
☆方式二 :使用插件进行加密
插件地址: https://github.com/MikeCoder/hexo-blog-encrypt
☆首页文章摘要图
☆方式一:只在首页显示,文章中不显示
打开 ~\blog\themes\next6.4\layout_macro\post.swig
搜索: post.description
下面添加:
1 |
|
然后在文章 中写:
1 | image: |
☆方式二:首页和文章中都显示
直接在文章 中写(默认支持):
1 | photos: |
☆文章置顶
打开 \blog\node_modules\hexo-generator-index\lib\generator.js
将内容修改为
1 | ; |
使用方法
在文章中添加 sticky 值,数值越大文章越靠前,如
1 | title: hexo优化基于NexT6.4 |