init
$ hexo init [folder] |
初始化网站。如果没有提供 folder,Hexo 将在当前目录中建立一个网站。
¥Initializes a website. If no folder is provided, Hexo will set up a website in the current directory.
此命令是运行以下步骤的快捷方式:
¥This command is a shortcut that runs the following steps:
将 hexo-starter(包括 hexo-theme-landscape)Git 克隆到当前目录或目标文件夹中(如果指定)。
¥Git clone hexo-starter including hexo-theme-landscape into the current directory or a target folder if specified.
使用包管理器安装依赖:Yarn 1、pnpm 或 npm,以安装的为准;如果安装了多个,则优先级如上所示。npm 默认与 Node.js 打包在一起。
¥Install dependencies using a package manager: Yarn 1, pnpm or npm, whichever is installed; if there are more than one installed, the priority is as listed. npm is bundled with Node.js by default.
new
$ hexo new [layout] <title> |
创建新文章。如果没有提供 layout,Hexo 将使用 _config.yml 中的 default_layout。使用布局 draft 创建草稿。如果 title 包含空格,请用引号括起来。
¥Creates a new article. If no layout is provided, Hexo will use the default_layout from _config.yml. Use the layout draft to create a draft. If the title contains spaces, surround it with quotation marks.
| 选项 | 描述 |
|---|---|
-p、--path |
帖子路径。自定义帖子的路径。 |
-r、--replace |
如果存在,则替换当前帖子。 |
-s、--slug |
帖子 slug。自定义帖子的 URL。 |
默认情况下,Hexo 将使用标题来定义文件的路径。对于页面,它将创建一个同名的目录并在其中创建一个 index.md 文件。使用 --path 选项覆盖该行为并定义文件路径:
¥By default, Hexo will use the title to define the path of the file. For pages, it will create a directory of that name and an index.md file in it. Use the --path option to override that behaviour and define the file path:
hexo new page --path about/me "About me" |
将在前言中创建标题为 “关于我” 的 source/about/me.md 文件。
¥will create source/about/me.md file with the title “About me” set in the front matter.
请注意,标题是必填项。例如,这不会导致你可能期望的行为:
¥Please note that the title is mandatory. For example, this will not result in the behaviour you might expect:
hexo new page --path about/me |
将在前言中创建标题为 “page” 的帖子 source/_posts/about/me.md。这是因为只有一个参数(page),而默认布局是 post。
¥will create the post source/_posts/about/me.md with the title “page” in the front matter. This is because there is only one argument (page) and the default layout is post.
generate
$ hexo generate |
生成静态文件。
¥Generates static files.
| 选项 | 描述 |
|---|---|
-d、--deploy |
生成完成后部署 |
-w、--watch |
监视文件更改 |
-b、--bail |
生成过程中如果抛出任何未处理的异常,则抛出错误 |
-f、--force |
强制重新生成 |
-c、--concurrency |
并行生成的最大文件数。默认为无穷大 |
publish
$ hexo publish [layout] <filename> |
发布草稿。
¥Publishes a draft.
server
$ hexo server |
启动本地服务器。默认情况下,这是在 http://localhost:4000/。
¥Starts a local server. By default, this is at http://localhost:4000/.
| 选项 | 描述 |
|---|---|
-p、--port |
覆盖默认端口 |
-s、--static |
仅提供静态文件 |
-l、--log |
启用日志器。覆盖日志器格式。 |
deploy
$ hexo deploy |
部署你的网站。
¥Deploys your website.
| 选项 | 描述 |
|---|---|
-g、--generate |
部署前生成 |
render
$ hexo render <file1> [file2] ... |
渲染文件。
¥Renders files.
| 选项 | 描述 |
|---|---|
-o、--output |
输出目的地 |
migrate
$ hexo migrate <type> |
来自其他博客系统的 迁移 内容。
¥Migrates content from other blog systems.
clean
$ hexo clean |
清除缓存文件(db.json)和生成的文件(public)。
¥Cleans the cache file (db.json) and generated files (public).
list
$ hexo list <type> |
列出所有路由。
¥Lists all routes.
version
$ hexo version |
显示版本信息。
¥Displays version information.
config
$ hexo config [key] [value] |
列出配置(_config.yml)。如果指定了 key,则仅显示配置中相应 key 的值;如果同时指定了 key 和 value,则配置中相应的 key 的值将更改为 value。
¥Lists the configuration (_config.yml). If key is specified, only the value of the corresponding key in the configuration is shown; if both key and value are specified, the value of the corresponding key in the configuration is changed to value.
选项
¥Options
安全模式
¥Safe mode
$ hexo --safe |
禁用加载插件和脚本。如果你在安装新插件后遇到问题,请尝试此操作。
¥Disables loading plugins and scripts. Try this if you encounter problems after installing a new plugin.
调试模式
¥Debug mode
$ hexo --debug |
将详细消息记录到终端和 debug.log。如果你在使用 Hexo 时遇到任何问题,请尝试此操作。如果你看到错误,请 提出 GitHub 问题。
¥Logs verbose messages to the terminal and to debug.log. Try this if you encounter any problems with Hexo. If you see errors, please raise a GitHub issue.
静默模式
¥Silent mode
$ hexo --silent |
使输出静音到终端。
¥Silences output to the terminal.
自定义配置文件路径
¥Customize config file path
$ hexo --config custom.yml |
使用自定义配置文件(而不是 _config.yml)。还接受以逗号分隔的 JSON 或 YAML 配置文件列表(无空格),这些文件将组合成单个 _multiconfig.yml。
¥Uses a custom config file (instead of _config.yml). Also accepts a comma-separated list (no spaces) of JSON or YAML config files that will combine the files into a single _multiconfig.yml.
$ hexo --config custom.yml,custom2.json |
显示草稿
¥Display drafts
$ hexo --draft |
显示草稿帖子(存储在 source/_drafts 文件夹中)。
¥Displays draft posts (stored in the source/_drafts folder).
自定义 CWD
¥Customize CWD
$ hexo --cwd /path/to/cwd |
自定义当前工作目录的路径。
¥Customizes the path of current working directory.