hexo + next 博客系统优化和常用插件

一、hexo-symbols-count-time

利用该插件可以增加文章字数统计及阅读时长功能

1.安装依赖

yarn add hexo-symbols-count-time --save

2.站点配置文件修改

# 增加字数统计
symbols_count_time:
  #文章内是否显示
  symbols: true
  time: true
  # 网页底部是否显示
  total_symbols: true
  total_time: true

3.主题配置文件修改

symbols_count_time:
  separated_meta: true
  item_text_post: true
  item_text_total: false
  awl: 2
  wpm: 300
  suffix: mins.

hexo默认的链接很长不符合我的风格,并且如果用文章ID用于链接,由于其自身的文章ID很长,不符合URL简短的规则。所以需要另外的方式去展示URL。

这里使用hexo-abbrlink这个插件生成URL。

1.安装依赖

npm install hexo-abbrlink --save

2.修改站点配置文件

permalink: :category/:abbrlink/

# abbrlink
abbrlink:
  alg: crc16  #support crc16(default) and crc32
  rep: dec    #support dec(default) and hex

3.清除缓存

hexo cleans

三、hexo-filter-date-from-git

可以根据文章提交到git的时间自动生成创建时间和更新时间

安装

yarn add hexo-filter-date-from-git --save

四、hexo-generator-searchdb

站内搜索插件

安装插件


yarn add hexo-generator-searchdb --save

配置站点配置文件

search:
  path: search.xml
  field: post
  format: html
  limit: 10000

配置主题配置文件

local_search:
  enable: true
  # If auto, trigger search by changing input.
  # If manual, trigger search by pressing enter key or search button.
  trigger: auto
  # Show top n results per article, show all results by setting to -1
  top_n_per_article: 1
  # Unescape html strings to the readable one.
  unescape: false

五、阅读全文配置

当文章非常多的时候,首页加载内容会非常多,也不方便阅读。此时增加阅读全文配置就非常重要了。

修改主题配置文件。

auto_excerpt: 
  # 表示开启阅读全文
  enable: true
  # 表示显示的字数
  length: 200

六、leancloud_visitors: 阅读次数统计

具体可以参考:https://leaferx.online/2018/02/11/lc-security/https://github.com/theme-next/hexo-leancloud-counter-security

可能出现的问题:配置完成后,仍然报错:Counter not initialized! See more at console err msg。可通过以下方式检查:

  1. 检查source目录下是否有 leancloud.memo 这个文件。
  2. 如果没有leancloud.memo这个文件,执行hexo cleanhexo d 生成这个文件。
  3. 如果有这个文件,检查文件中是否含有文章相对应的记录,即看里面有没有title是该文章的标题。因为正常情况下,如果有一篇文章的标题是hello world,会有一个类似{“title”:”Hello World”,”url”:”/uncategorized/16107/“}这样的记录。
  4. 如果步骤3中不存在相应的记录,手动再执行一次hexo cleanhexo d
  5. 执行完4后如果仍然没有相应的记录的话,那就先把 leancloud.memo 文件删除,再次执行hexo cleanhexo d 即可。

   转载规则


《hexo + next 博客系统优化和常用插件》 孤独如梦 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
【dubbo系列】 02-基于spring加载dubbo配置 【dubbo系列】 02-基于spring加载dubbo配置
前言本文主要dubbo和spring的结合使用,在spring配置文件中配置dubbo的相关信息。 同时,本文代码基于01 dubbo系列 | dubbo快速入门。 环境需要引入spring相关的依赖。 第一步:dubbo-demo-pro
2019-05-31
下一篇 
【架构设计】28-异地多活设计4大技巧 【架构设计】28-异地多活设计4大技巧
前言相比同城异区和跨国异地,跨城异地其复杂度是最高的。跨城异地的架构设计主要是解决在数据不一致的情况下,业务不受影响或者影响很小。下面主要介绍一些跨城异地的一些设计技巧:保证核心业务的异地多活、保证核心数据最终一致性、采用多种手段同步数据、
2019-05-29
  目录