Merge pull request #8 from curbengh/deprecate
[hexo-nofollow.git] / README.md
blob973c7915e596438860c76f35f2a82e9414e19f5e
1 # hexo-nofollow
3 ## Deprecation
5 This plugin has been deprecated. I'm now working on [hexo-filter-nofollow](https://github.com/hexojs/hexo-filter-nofollow).
7 If you prefer this plugin and doesn't want to see the deprecation warning,
9 ``` diff
10 package.json
11 -  "hexo-nofollow": "^2.0.0"
12 +  "hexo-nofollow": "curbengh/hexo-nofollow"
13 ```
15 ---
17 [![npm version](https://badge.fury.io/js/hexo-nofollow.svg)](https://www.npmjs.com/package/hexo-nofollow)
18 [![Build Status](https://travis-ci.com/curbengh/hexo-nofollow.svg?branch=master)](https://travis-ci.com/curbengh/hexo-nofollow)
20 Adds nofollow attribute to all external links in your hexo blog posts automatically.
22 This is an updated version of [hexo-autonofollow](https://github.com/liuzc/hexo-autonofollow). All the options are the same, so you can use this as a drop-in replacement.
24 ## Features
25 * Add `rel="external nofollow noopener noreferrer"` to all external links for security, privacy and SEO. [Read more](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types).
26 * Add `target="_blank"`, Open external links in new window or tab. This can be disabled, see below.
28 Hexo doesn't insert `target="_blank"` to all external links even if you set `external_link: true` (default value) in the _config.yml.
29 This plugin make sure all external links are processed.
31 For example,
32 ```markdown
33 [example-link](https://example.com)
34 ```
35 Becomes,
36 ```html
37 <a href="https://example.com" rel="external nofollow noopener noreferrer" target="_blank">example-link</a>
38 ```
40 ## Install
41 ``` bash
42 $ npm install hexo-nofollow --save
43 ```
45 ## Usage
46 To enable this plugin, insert the following to `_config.yml`:
47 ``` yaml
48 nofollow:
49   enable: true
50 ```
51 To exclude certain links, see below.
53 ## Options
54 ```yaml
55 nofollow:
56   enable: true
57   exclude:
58     - 'exclude1.com'
59     - 'exclude2.com'
60 external_link: true
61 ```
63 - **enable** - Enable the plugin. Defaults to `false`.
64 - **exclude** - Exclude hostname. Specify subdomain when applicable, including `www`
65   - `'exclude1.com'` does not apply to `www.exclude1.com` nor `en.exclude1.com`.
66 - **external_link** - Add `target="_blank"`. [Defaults](https://hexo.io/docs/configuration#Writing) to `true`. [Recommend](https://css-tricks.com/use-target_blank/) to set it to false.
68 ***Note:*** **external_link** setting is already in the default `_config.yml`.
70 ## Credits
71 All credits go to the following work:
72 - [hexo-autonofollow](https://github.com/liuzc/hexo-autonofollow) by liuzc
73 - Regex is [created by](https://github.com/hexojs/hexo/pull/3685) SukkaW
74 - `target="_blank"` behaviour is noticed through this [commit](https://github.com/SukkaW/hexo-filter-nofollow/commit/6c5f49fb551237b42413c158b9294d58c4c8b221)