Helper

A helper makes it easy to quickly add snippets to your templates. We recommend using helpers instead of templates when you’re dealing with more complicated code.

Helpers can not be accessed from source files.

Synopsis

hexo.extend.helper.register(name, function(){
// ...
});

Example

hexo.extend.helper.register('js', function(path){
return '<script type="text/javascript" src="' + path + '"></script>';
});
<%- js('script.js') %>
// <script type="text/javascript" src="script.js"></script>

FAQ

Where to place custom helper?

Place it under themes/<yourtheme>/scripts