This documentation provides more detailed information about the API and will be particularly helpful for people who want to modify the Hexo source code or write new plugins. If you are interested in more basic usage of Hexo, please refer to the docs instead.
Please note that this documentation is only valid for Hexo 3 and above.
First, we have to create a Hexo instance. A new instance takes two arguments: the root directory of the website,
base_dir, and an object containing the initialization options. Next, we initialize this instance by calling the
init method on it, which will then cause Hexo to load its configuration and plugins.
var Hexo = require('hexo');
||Enable debug mode. Display debug messages in the terminal and save
||Enable safe mode. Don’t load any plugins.||
||Enable silent mode. Don’t display any messages in the terminal.||
||Specify the path of the configuration file.||
Hexo provides two methods for loading files:
load is used for loading all files in the
source folder as well as the theme data.
watch does the same things
load does, but will also start watching for file changes continuously.
Both methods will load the list of files and pass them to the corresponding processors. After all files have been processed, they will call upon the generators to create the routes.
Any console command can be called explicitly using the
call method on the Hexo instance. Such a call takes two arguments: the name of the console command, and an options argument. Different options are available for the different console commands.
You should call the
exit method upon successful or unsuccessful completion of a console command. This allows Hexo to exit gracefully and finish up important things such as saving the database.