There are two methods for rendering files or strings in Hexo: the asynchronous
hexo.render.render method and the synchronous
hexo.render.renderSync method. Unsurprisingly, the two methods are very similar so only the asynchronous
hexo.render.render will be further discussed in the below paragraphs.
When rendering a string, you must specify an
engine to let Hexo know which rendering engine it should use.
When rendering a file, it’s not necessary to specify an
engine because Hexo will detect the relevant rendering engine automatically based on the extension of the file. Of course, you are also allowed to explicitly define the
You can pass in an options object as the second argument.
When rendering is complete, Hexo will execute the corresponding
You can use the
isRenderableSync method to check whether a file path is renderable. Only when a corresponding renderer has been registered will this method return true.
getOutput method to get the extension of the rendered output. If a file is not renderable, the method will return an empty string.