# 指令
[](https://github.com/hexojs/site/edit/master/source/zh-cn/docs/commands.md "改進本文")
## [](https://hexo.io/zh-cn/docs/commands.html#init "init")init
~~~
$ hexo init [folder]
~~~
新建一個網站。如果沒有設置?`folder`?,Hexo 默認在目前的文件夾建立網站。
## [](https://hexo.io/zh-cn/docs/commands.html#new "new")new
~~~
$ hexo new [layout] <title>
~~~
新建一篇文章。如果沒有設置?`layout`?的話,默認使用?[_config.yml](https://hexo.io/zh-cn/docs/configuration.html)?中的?`default_layout`?參數代替。如果標題包含空格的話,請使用引號括起來。
## [](https://hexo.io/zh-cn/docs/commands.html#generate "generate")generate
~~~
$ hexo generate
~~~
生成靜態文件。
| 選項 | 描述 |
| --- | --- |
| `-d`,?`--deploy` | 文件生成后立即部署網站 |
| `-w`,?`--watch` | 監視文件變動 |
## [](https://hexo.io/zh-cn/docs/commands.html#publish "publish")publish
~~~
$ hexo publish [layout] <filename>
~~~
發表草稿。
## [](https://hexo.io/zh-cn/docs/commands.html#server "server")server
~~~
$ hexo server
~~~
啟動服務器。默認情況下,訪問網址為:?`http://localhost:4000/`。
| 選項 | 描述 |
| --- | --- |
| `-p`,?`--port` | 重設端口 |
| `-s`,?`--static` | 只使用靜態文件 |
| `-l`,?`--log` | 啟動日記記錄,使用覆蓋記錄格式 |
## [](https://hexo.io/zh-cn/docs/commands.html#deploy "deploy")deploy
~~~
$ hexo deploy
~~~
部署網站。
| 參數 | 描述 |
| --- | --- |
| `-g`,?`--generate` | 部署之前預先生成靜態文件 |
## [](https://hexo.io/zh-cn/docs/commands.html#render "render")render
~~~
$ hexo render <file1> [file2] ...
~~~
渲染文件。
| 參數 | 描述 |
| --- | --- |
| `-o`,?`--output` | 設置輸出路徑 |
## [](https://hexo.io/zh-cn/docs/commands.html#migrate "migrate")migrate
~~~
$ hexo migrate <type>
~~~
從其他博客系統?[遷移內容](https://hexo.io/zh-cn/docs/migration.html)。
## [](https://hexo.io/zh-cn/docs/commands.html#clean "clean")clean
~~~
$ hexo clean
~~~
清除緩存文件 (`db.json`) 和已生成的靜態文件 (`public`)。
## [](https://hexo.io/zh-cn/docs/commands.html#list "list")list
~~~
$ hexo list <type>
~~~
列出網站資料。
## [](https://hexo.io/zh-cn/docs/commands.html#version "version")version
~~~
$ hexo version
~~~
顯示 Hexo 版本。
## [](https://hexo.io/zh-cn/docs/commands.html#選項 "選項")選項
### [](https://hexo.io/zh-cn/docs/commands.html#安全模式 "安全模式")安全模式
~~~
$ hexo --safe
~~~
在安全模式下,不會載入插件和腳本。當您在安裝新插件遭遇問題時,可以嘗試以安全模式重新執行。
### [](https://hexo.io/zh-cn/docs/commands.html#調試模式 "調試模式")調試模式
~~~
$ hexo --debug
~~~
在終端中顯示調試信息并記錄到?`debug.log`。當您碰到問題時,可以嘗試用調試模式重新執行一次,并?[提交調試信息到 GitHub](https://github.com/hexojs/hexo/issues/new)。
### [](https://hexo.io/zh-cn/docs/commands.html#簡潔模式 "簡潔模式")簡潔模式
~~~
$ hexo --silent
~~~
隱藏終端信息。
### [](https://hexo.io/zh-cn/docs/commands.html#自定義配置文件的路徑 "自定義配置文件的路徑")自定義配置文件的路徑
~~~
$ hexo --config custom.yml
~~~
自定義配置文件的路徑,執行后將不再使用?`_config.yml`。
### [](https://hexo.io/zh-cn/docs/commands.html#顯示草稿 "顯示草稿")顯示草稿
~~~
$ hexo --draft
~~~
顯示?`source/_drafts`?文件夾中的草稿文章。
### [](https://hexo.io/zh-cn/docs/commands.html#自定義-CWD "自定義 CWD")自定義 CWD
~~~
$ hexo --cwd /path/to/cwd
~~~
自定義當前工作目錄(Current working directory)的路徑。