Hexo command system¶
The Hexo command system provides a CLI interface for managing the content and structure of a static blog. It includes specific commands for creating posts, managing drafts, and generating independent pages^[600-developer__blog__hexo-blog__Hexo-command.md].
Creating Posts¶
New blog posts are generated using the new post command^[600-developer__blog__hexo-blog__Hexo-command.md]. This command utilizes templates located in the scaffolds directory to create the file^[600-developer__blog__hexo-blog__Hexo-command.md].
Syntax:
hexo new post "文章名称"
This command is functionally equivalent to the shorter syntax hexo new "文章名称"^[600-developer__blog__hexo-blog__Hexo-command.md].
Draft Management¶
Hexo includes a specific workflow for unpublished content using the drafts layout^[600-developer__blog__hexo-blog__Hexo-command.md]. This allows users to manage work that is not yet ready for publication.
- Create Draft: To create a new draft, use
hexo new drafts "文章名称"^[600-developer__blog__hexo-blog__Hexo-command.md]. - Publish: When a draft is complete,
hexo publish "文章名称"moves the file from the drafts folder to the posts directory^[600-developer__blog__hexo-blog__Hexo-command.md]. - Preview: Drafts are hidden by default. To view them during local development, the server must be started with the
--draftsflag^[600-developer__blog__hexo-blog__Hexo-command.md]:hexo server --drafts
Creating Pages¶
In addition to posts, Hexo can generate standalone pages that do not belong to the post chronology^[600-developer__blog__hexo-blog__Hexo-command.md]. Executing hexo new page "文章名称" creates a new folder for the page^[600-developer__blog__hexo-blog__Hexo-command.md].
The resulting URL structure follows the format http://localhost:4000/"文章名称"/index.html^[600-developer__blog__hexo-blog__Hexo-command.md].
Layout System¶
The visual rendering of these commands is determined by the theme's layout system. The structure typically involves a main layout.ejs file which includes specific partials like index.ejs to render the content^[600-developer__blog__hexo-blog__Hexo-command.md].
Related Concepts¶
- [[Templates]]
- [[Static Site Generator]]
Sources¶
^[600-developer__blog__hexo-blog__Hexo-command.md]