There are several hexo plugins for post encrypting. After checking out some of them, I found this node.js package quite good.(others may work, though I found them somewhat confusing)
You can either choose to follow the tutorial on https://npmjs.com or to follow mine. I have found out some deficiencies of the plugin, however, and have come up with some solutions, so you may want to see my suggestions.
The installation is quite simple:
- Add ‘“hexo-blog-encrypt”: “2.0.*”‘ to your hexo package.json.
- Under your root directory for hexo blog, run
Note that before running
npm install, you need to check there are no other uninstalled package names inside
package.json, or they will also be installed.
_config.yml file, add these lines:
Then in the front matter of your post, you will also have to add these lines:
There is one problem with this plugin. While it will encrypt its content and thumbnail, sometimes on the sidebar of your blog webpage your thumbnail will still show. For example, in theme Hueman, your thumbnail will show in the “RECENTS” column.
On the other hand, Normally we would like our post to be beautiful even though it is encrypted. The better solution for this is to explicitly enable a thumbnail that can be shown. Basically this plugin works to encrypt all data(assets) of your post. However, if we use pictures placed outside this post’s asset folder, we will be able to display it correctly.
/sources folder, create a subfolder named
images, and then use
thumbnail: /images/thumbnail.jpg in your front matter. When the site is generated, the picture will be exactly stored in that path, which will not be encrypted. This way, you will be able to keep your beautiful thumbnail just as I did here!
However, this plugin(as of 10/2017) only supports the encryption of posts, not pages for hexo. To see a difference between hexo post and page, visit this page.