Hexo博客常用插件及用法

hexo-autonofollow

Github:https://github.com/liuzc/hexo-autonofollow

简介:自动为站外链接添加nofollow属性

安装:

$ npm install hexo-autonofollow --save

配置:

在博客配置文件_config.yml中添加

nofollow:
enable: true
exclude:
- exclude1.com
- exclude2.com
  • enable - 是否启用
  • exclude - 排除域名

hexo-baidu-url-submit

Github:https://github.com/huiwang/hexo-baidu-url-submit

简介:主动推送Hexo博客新链接至百度搜索引擎,解决百度爬虫被禁止访问的问题,提升网站收录质量和速度。

安装:

$ npm install hexo-baidu-url-submit --save

配置:

在博客配置文件_config.yml中添加

baidu_url_submit:
count: 1 ## 提交最新的一个链接
host: blog.cofess.com ## 在百度站长平台中注册的域名
token: your_token ## 请注意这是您的秘钥, 所以请不要把博客源代码发布在公众仓库里!
path: baidu_urls.txt ## 文本文档的地址, 新链接会保存在此文本文档里
  • token - 您得注册百度站长工具,然后在工具->网页抓取->链接提交里找到你的密匙。

其次,_config.ym文件中url的值, 必须是百度站长平台注册的域名, 比如:

# URL
url: blog.cofess.com
root: /
permalink: :year/:month/:day/:title/

最后,加入新的deployer:

deploy:
- type: baidu_url_submitter

执行hexo deploy的时候,新的链接就会被推送百度了。

hexo-generator-feed

Github:https://github.com/hexojs/hexo-generator-feed

简介:RSS的生成插件,你可以在配置显示你站点的RSS,文件路径\atom.xml。

安装:

$ npm install hexo-generator-feed --save

配置:

在博客配置文件_config.yml中添加

feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
  • type - Feed type. (atom/rss2)
  • path - Feed path. (Default: atom.xml/rss2.xml)
  • limit - Maximum number of posts in the feed (Use 0 or false to show all posts)
  • hub - URL of the PubSubHubbub hubs (Leave it empty if you don’t use it)
  • content - (optional) set to ‘true’ to include the contents of the entire post in the feed.

hexo-generator-sitemap

Github:https://github.com/hexojs/hexo-generator-sitemap

简介:生成博客的sitemap。

安装:

$ npm install hexo-generator-sitemap --save

配置:

在博客配置文件_config.yml中添加

sitemap:
path: sitemap.xml

hexo-generator-baidu-sitemap

Github:https://github.com/coneycode/hexo-generator-baidu-sitemap

简介:生成博客的sitemap(针对百度)。

安装:

$ npm install hexo-generator-baidu-sitemap --save

配置:

在博客配置文件_config.yml中添加

baidusitemap:
path: baidusitemap.xml

hexo-generator-json-content

Github:https://github.com/alexbruno/hexo-generator-json-content

简介:用于生成静态站点数据,提供搜索功能的数据源。

安装:

$ npm install hexo-generator-json-content --save

配置:

在博客配置文件_config.yml中添加

jsonContent:
ignore:
- path/to/a/page
- url/to/one/post
- an-entire-category
- specific.file
- .ext # a file extension

hexo-neat

Github:https://github.com/rozbo/hexo-neat

简介:自动压缩html、css、js代码

安装:

$ npm install hexo-neat --save

配置:

在博客配置文件_config.yml中添加

neat_enable: true

压缩html代码

neat_html:
enable: true
exclude:

压缩CSS

neat_css:
enable: true
exclude:
- '*.min.css'

压缩JS

neat_js:
enable: true
mangle: true
output:
compress:
exclude:
- '*.min.js'

hexo-translate-title

Github:https://github.com/cometlj/hexo-translate-title

简介:使用Google翻译,百度翻译和有道翻译将Hexo文章中的汉字标题转成英文标题

安装:

$ npm install hexo-translate-title --save

配置:

在博客配置文件_config.yml中添加

translate_title:
translate_way: google #google | baidu | youdao
youdao_api_key: XXX
youdao_keyfrom: XXX
is_need_proxy: true #true | false
proxy_url: http://localhost:4000

注意:判断是否需要配置google本地代理,如果没有被墙,请将_config.yml下的is_need_proxy: true改为false。如果设置为true,请设置本地代理地址

hexo-wordcount

Github:https://github.com/willin/hexo-wordcount

简介:为文章添加文章字数统计、文章预计阅读时间

安装:

$ npm install hexo-wordcount --save

使用:

通过以上安装后,你可以在你的模板文件加入以下相关的标签实现本插件的功能
**字数统计:**WordCount
**阅读时长预计:**Min2Read
总字数统计: TotalCount

hexo-generator-restful

Github:https://github.com/yscoder/hexo-generator-restful

简介:RESTful JSON数据生成插件。

安装:

$ npm install hexo-generator-restful --save

配置:

以下为默认配置,属性值为 false 表示不生成。

restful:
# site 可配置为数组选择性生成某些属性
# site: ['title', 'subtitle', 'description', 'author', 'since', email', 'favicon', 'avatar']
site: true # hexo.config mix theme.config
posts_size: 10 # 文章列表分页,0 表示不分页
posts_props: # 文章列表项的需要生成的属性
title: true
slug: true
date: true
updated: true
comments: true
path: true
excerpt: false
cover: true # 封面图,取文章第一张图片
content: false
keywords: false
categories: true
tags: true
categories: true # 分类数据
tags: true # 标签数据
post: true # 文章数据
pages: false # 额外的 Hexo 页面数据, 如 About