Hexo has a powerful plugin system, which makes you easy to extend functions without modifying source code of the core module. There’re two kinds of plugins in Hexo:
scripts folder and they’ll be loaded once Hexo is initialized.
If your code is complicated or you want to publish it to NPM registry, it’s recommended to use a plugin. First, create a folder in
node_modules folder. The name of the folder must be started with
hexo- so it could be loaded by Hexo.
The folder must be contained at least 2 files: One is the main program and the other is
package.json describing the purpose and the dependencies of the plugin.
You should at least describe
package.json. For example:
You can make use of the official tools provided by Hexo to accelerate development:
- hexo-fs：File IO
- hexo-i18n：Localization (i18n)
- hexo-pagination：Generate pagination data
- Fork hexojs/site
Clone the repository to your computer and install dependencies.
$ git clone https://github.com/<username>/site.git
$ cd site
$ npm install
source/_data/_plugins.ymland add your plugin. For example:
- name: hexo-server
description: Server module for Hexo.
Push the branch.
- Create a pull request and describe the change.