LinuxCommandLibrary

hexo

Generate static websites using Hexo

TLDR

Initialize a website

$ hexo init [path/to/directory]
copy

Create a new article
$ hexo new [layout] [title]
copy

Generate static files
$ hexo generate
copy

Start a local server
$ hexo server
copy

Deploy the website
$ hexo deploy
copy

Clean the cache file (db.json) and generated files (public/)
$ hexo clean
copy

SYNOPSIS

hexo <command> [options]

PARAMETERS

-V, --version
    Display Hexo version number

-h, --help
    Display help message

-d, --debug
    Enable debug mode with verbose logs

-s, --safe
    Disable cache for safe execution

-c, --cache
    Force cache update

-t, --theme <name>
    Specify theme name

init [folder]
    Initialize a new Hexo site

new [layout] <title>
    Create a new post

generate, g
    Generate static files

clean
    Clean cache and generated files

server, s [port]
    Start development server

deploy, d [platform]
    Deploy site to platform

publish [layout] <title>
    Publish draft as post

list, l
    List all posts

render <file> ...
    Render specific file

migrate <from>
    Migrate from other system

DESCRIPTION

Hexo is a minimalist, fast, and powerful static site generator built with Node.js, ideal for blogs and static websites. The hexo command provides a comprehensive CLI to scaffold sites, manage content, generate output, preview changes, and deploy to hosts.

Powered by a modular plugin system, Hexo supports Markdown, numerous themes, and integrations with services like GitHub Pages, Netlify, and Vercel. Start with hexo init myblog to create a site skeleton, add posts via hexo new post "My Title", generate static files with hexo generate, and serve locally using hexo server. Deployment is configured in _config.yml and executed with hexo deploy.

Hexo's speed comes from efficient rendering and caching, handling thousands of posts seamlessly. Customize via themes from its marketplace, extend with 100+ plugins for SEO, RSS, sitemaps, and more. No database or server-side runtime needed post-generation, ensuring high performance and security.

CAVEATS

Requires Node.js (≥14.0.0) and global install via npm install hexo-cli -g. Not a native Linux binary; paths depend on npm prefix. Some commands need configuration in _config.yml. Large sites may require memory tweaks.

INSTALLATION

npm install hexo-cli -g
Then hexo init <folder> && cd <folder> && npm install

QUICK START

hexo new "Hello World"
hexo generate
hexo server - Access at http://localhost:4000

CONFIGURATION

Edit _config.yml for site title, URL, theme, deploy settings

HISTORY

Created in 2013 by Tommy Chen (iChenlei) as a Node.js alternative to static generators like Jekyll. Gained popularity for speed and simplicity; version 4.0 (2018) introduced major refactoring. Now v7.x, actively maintained by a global community with 40k+ GitHub stars.

SEE ALSO

node(1), npm(1), hugo(1)

Copied to clipboard