Hexo Static Site Generator
Hexo is a fast, simple, and powerful blog framework for Node.js, designed for generating static websites. The current stable version is 8.1.1, with minor and patch releases occurring frequently, typically every few weeks to months, and major versions bringing significant changes roughly annually. It features blazing-fast content generation, robust support for GitHub Flavored Markdown, and compatibility with most Octopress plugins. Key differentiators include its one-command deployment capabilities to platforms like GitHub Pages and Heroku, a highly extensible API for plugin development, and a rich ecosystem boasting hundreds of themes and plugins. Hexo primarily targets developers and bloggers who prefer a static site approach with a command-line interface.
Common errors
-
Error: Cannot find module 'hexo-tag-embed'
cause Upgrading to Hexo v7.0.0 or later without installing the `hexo-tag-embed` plugin, while still using old embed tags like `gist`, `youtube`, etc., in your posts.fixInstall the compatibility plugin: `npm install hexo-tag-embed --save` -
Error: Node.js version x.y.z is not supported. Please upgrade Node.js to >=20.19.0.
cause Running Hexo v8.0.0 or newer with an unsupported Node.js version (e.g., Node.js 16 or 18).fixUpdate your Node.js environment to version 20.19.0 or higher. -
Port XXXXX is already in use, start another Hexo instance with --port YYYYY
cause Another process is already using the default port (4000) or the port specified for `hexo server`.fixEither stop the conflicting process or start Hexo server on a different port: `hexo server --port 5000`
Warnings
- breaking Hexo v8.0.0 dropped support for Node.js 16 and Node.js 18. This means users upgrading to v8.0.0 or later must be running Node.js 20.19.0 or higher.
- breaking In Hexo v7.0.0, several built-in tags (such as `gist`, `youtube`, `jsfiddle`, and `vimeo`) were removed from the core. Using these tags in existing posts after upgrading will result in errors or broken content.
- gotcha When developing plugins or themes, changes often require restarting the `hexo server` process to reflect updates, especially for generators, filters, and new helpers. Incremental rebuilds only apply to content changes by default.
Install
-
npm install hexo -
yarn add hexo -
pnpm add hexo
Imports
- Hexo
const Hexo = require('hexo');import { Hexo } from 'hexo'; - HexoConfig
import { HexoConfig } from 'hexo';import type { HexoConfig } from 'hexo'; - Hexo CLI
npm install hexo-cli -g
Quickstart
npm install hexo-cli -g hexo init my-blog cd my-blog npm install # Install dependencies for the new blog hexo new "My First Post" hexo generate hexo server