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> [<args>] [<options>]

Common commands include: init, new, generate (g), server (s), deploy (d), clean.

PARAMETERS

init [folder]
    Initializes a new Hexo project in the specified folder. If no folder is specified, it initializes in the current directory.

new
    Creates a new post, page, draft, or photo with the specified layout (e.g., 'post', 'page') and title.

generate / g
    Generates static HTML, CSS, and JavaScript files from your Hexo source content. This prepares your site for deployment.

server / s
    Starts a local development server, allowing you to preview your blog in a web browser before deployment. Useful for real-time changes.

deploy / d
    Deploys the generated static files to a remote server or hosting service configured in your _config.yml file.

clean
    Cleans the cache file (db.json) and the generated public files, useful for troubleshooting or before a fresh generation.

version
    Displays the current Hexo version along with Node.js and npm versions.

DESCRIPTION

Hexo is an open-source, Node.js-based static site generator primarily designed for creating and managing blogs. It allows users to write content in Markdown, generate static HTML files, and deploy them easily to various hosting services.

Known for its speed and simplicity, Hexo takes plain text files (e.g., Markdown for posts, YAML for configuration) and transforms them into a complete, ready-to-deploy website. It automates common blogging tasks such as generating archives, categories, tags, and permalinks. Its extensibility through a rich ecosystem of themes and plugins makes it a popular choice for developers looking for a lightweight yet powerful blogging solution.

CAVEATS

Hexo requires Node.js and npm (Node Package Manager) to be installed on your system. It is not a native Linux command or a pre-installed utility; it must be installed via npm (e.g., npm install -g hexo-cli).

THEMES AND PLUGINS

Hexo boasts a rich ecosystem of community-contributed themes for customizing the look and feel, and plugins for extending functionality (e.g., SEO, sitemaps, analytics, deployment methods).

MARKDOWN SUPPORT

Content creation in Hexo is primarily done using Markdown, making it easy and intuitive to write blog posts and pages without needing to write raw HTML.

HISTORY

Hexo was created by Tommy Chen and first released around 2012-2013. It quickly gained popularity within the Node.js community for its focus on speed, simplicity, and its ability to leverage Node.js for static site generation, providing an alternative to Ruby-based generators like Jekyll.

SEE ALSO

Jekyll(1), Hugo(1), Gatsby(1), Next.js(1)

Copied to clipboard