hexo/filter/locals

Register the Hexo filter for merging theme and site config, and add all helper functions to a dedicated property (helper) in the locals.

(require("hexo/filter/locals"))(hexo)

Register the Hexo filter for merging theme and site config, and add all helper functions to a dedicated property (helper) in the locals.

This filter will try to merge

  • the post/page config defined in the Markdown file's front-matter,
  • post/page config defined in themes/[theme_name]/_config.post.yml or themes/[theme_name]/_config.page.yml,
  • post/page layout config defined in [site_root]/_config.post.yml or [site_root]/_config.page.yml,
  • theme config defined in themes/[theme_name]/_config.yml or node_modules/hexo-theme-[theme_name]/_config.yml if it is installed as an NPM package,
  • and the site config defined in _config.yml,
in the above order (the former config will overwrite later ones). This allow the user to customize the theme for each post/page, as well as for all post or pages.
It also adds a new variable named helper, containing all Hexo helper functions, to the page locals so that you can them through it instead. It is useful for passing helper functions to the cacheable view components.

NOTE: This filter must be registered before any other Hexo extensions or views in order to take effect.

Source:
Parameters:
Name Type Description
hexo Hexo The Hexo instance.