Hexo Official Website Documentation

repository·master·Indexed 20 days ago

https://github.com/hexojs/site

Documentation and source for the Hexo official website. Hexo is a Node.js-powered static site generator featuring a powerful API and plugin system. This repository includes guides on local setup, ESLint configuration, and detailed technical notes on features such as fragment caching, relative links via the url_for helper, server middleware registration, multi-language support, and migration paths for versions 3.0 and 3.8.

Tokens
56.2K
Snippets
261
Records
398
Agent score
72%

What's inside hexojs-site

  1. Hexo 8.0.0 New Features and Fixes Overview

    master

    Hexo 8.0.0 includes several key improvements:

    New Features

    • Hexo Context Binding: The hexo context is now bound to helper function callbacks.
    • URL Config Validation: Added validation for url configuration.
    • Permalink Variable: Added timestamp variable for permalinks.
    • Backtick Code Blocks: Support for additional configuration options.
    • Stricter Config Loading: load_config now enforces stricter extension checks.

    Key Fixes

    • Fixed hexo.locals.get('posts') to ensure all posts are displayed.
    • Fixed parsing errors for code blocks located within list items.
    • Fixed HTML escaping in the titles of code and include_code tags.
    • Improved Swig tag handling to backtrack when tags are incomplete.
  2. Key changes in Hexo 3.0

    master

    Hexo 3.0 introduces a modular architecture and several new features:

    • Modularization: The CLI is now a standalone module (hexo-cli). The core module is slimmer, with generators, deployers, and the server moved to separate modules.
    • New Generator API: The API for writing generators has changed significantly.
    • Async Tag Plugins: Tag plugins now support asynchronous operations.
    • Asset Management: New tag plugins allow including assets in posts: post_path, post_link, asset_path, asset_link, and asset_img.
    • Timezone Support: You can now define a specific timezone for your site.
  3. What is a Box in Hexo

    master

    A Box is a container used for processing files within a specific folder. Hexo utilizes two primary boxes:

    • hexo.source: Used to process the source folder.
    • hexo.theme: Used to process the theme folder.

    Boxes manage file loading, path matching, and the execution of processors to transform or handle file content.

  4. What is Front-matter and how to use it

    master

    Front-matter is a block of YAML or JSON placed at the very beginning of a file to configure settings for that specific piece of content (post or page).

    • YAML: Terminated by three dashes (---).
    • JSON: Terminated by three semicolons (;;;).
    ---
    title: Hello World
    date: 2013/7/13 20:46:25
    ---
  5. Configure alternate theme configuration files

    master

    Themes can now support alternate configuration files. Instead of only using the main _config.yml, a theme can look for a file named _config.[name].yml in the root folder (e.g., _config.landscape.yml for the landscape theme).

    This allows for easier management of multiple theme settings without cluttering the primary configuration.

  6. How Hexo manages the Cache of Rendered HTML

    master

    Hexo uses a Cache of Rendered HTML mechanism to improve performance. To optimize memory usage, the behavior of this cache differs based on the command used:

    • hexo g (Generation): The cache is disabled during generation to reduce memory consumption, as each route is typically only used once during this process.
    • hexo s (Server): The cache is enabled during the server process to speed up local previewing and development.
  7. Use scaffolds to template new posts

    master

    When you run hexo new, Hexo uses a template file from the scaffolds folder to build the new file. If you run hexo new photo "My Gallery", Hexo looks for photo.md in the scaffolds folder.

    Available Scaffold Placeholders:

    • layout: The layout assigned to the post
    • title: The title of the post
    • date: The file creation date
    $ hexo new photo "My Gallery"
  8. Understand Hexo generation performance: Cold vs Hot generation

    master

    Hexo performance is measured using two types of generation processes:

    1. Cold generation: Occurs when you run hexo clean before hexo g. This forces Hexo to re-render everything from scratch.
    2. Hot generation: Occurs when you run hexo g without cleaning first. Hexo utilizes the warehouse (db.json) to cache rendered contents and only re-renders what has changed.

    Understanding these modes helps you gauge the actual impact of changes to your site's content versus changes to the Hexo engine itself.

  9. Understand template mapping for pages

    master

    Hexo uses specific templates to define the presentation of different page types. Every theme must contain at least an index template. If a specific template is missing, Hexo uses a fallback mechanism as defined below:

    TemplatePageFallback
    indexHome page
    postPostsindex
    pagePagesindex
    archiveArchivesindex
    categoryCategory archivesarchive
    tagTag archivesarchive