hexo 问题解惑&&各种插件安装
summer13
一,高亮
由于 Hexo 自带的代码高亮主题显示不好看,所以主题中使用到了 hexo-prism-plugin 的 Hexo 插件来做代码高亮,安装命令如下:
bash
npm i -S hexo-prism-plugin
然后,修改 Hexo 根目录下 _config.yml 文件中 highlight.enable 的值为 false,并新增 prism 插件相关的配置,主要配置如下:
highlight:
enable: false
prism_plugin:
mode: ‘preprocess’ # realtime/preprocess
theme: ‘tomorrow’
line_number: false # default false
custom_css:
二,搜索
本主题中还使用到了 hexo-generator-search 的 Hexo 插件来做内容搜索,安装命令如下:
bash
npm install hexo-generator-search –save
在 Hexo 根目录下的 _config.yml 文件中,新增以下的配置项:
yaml
search:
path: search.xml
field: post
三,中文链接转拼音(可选的)
如果你的文章名称是中文的,那么 Hexo 默认生成的永久链接也会有中文,这样不利于 SEO,且 gitment 评论对中文链接也不支持。我们可以用 hexo-permalink-pinyin Hexo 插件使在生成文章时生成中文拼音的永久链接。
安装命令如下:
bash
npm i hexo-permalink-pinyin –save
在 Hexo 根目录下的 _config.yml 文件中,新增以下的配置项:
yaml
permalink_pinyin:
enable: true
separator: ‘-‘ # default: ‘-‘
四,文章字数统计插件(可选的)
如果你想要在文章中显示文章字数、阅读时长信息,可以安装 hexo-wordcount插件。
安装命令如下:
bash
npm i –save hexo-wordcount
然后只需在本主题下的 _config.yml 文件中,激活以下配置项即可:
yaml
wordCount:
enable: false # 将这个值设置为 true 即可.
postWordCount: true
min2read: true
totalCount: true
五,添加 RSS 订阅支持(可选的)
本主题中还使用到了 hexo-generator-feed 的 Hexo 插件来做 RSS,安装命令如下:
bash
npm install hexo-generator-feed –save
在 Hexo 根目录下的 _config.yml 文件中,新增以下的配置项:
yaml
feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ‘ ‘
order_by: -date
执行 hexo clean && hexo g 重新生成博客文件,然后在 public 文件夹中即可看到 atom.xml 文件,说明你已经安装成功了。
六,hexo可视化编辑
先安装hexo admin
npm install –save hexo-admin
安装完成后启动服务
hexo server -d
然后打开localhost:4000/admin/就可以了然后打开