{% raw %}
# 部署
Hexo 提供了快速方便的一鍵部署功能,讓您只需一條命令就能將網站部署到服務器上。
```
$ hexo deploy
```
在開始之前,您必須先在 `_config.yml` 中修改參數,一個正確的部署配置中至少要有 `type` 參數,例如:
```
deploy:
type: git
```
您可同時使用多個 deployer,Hexo 會依照順序執行每個 deployer。
```
deploy:
- type: git
repo:
- type: heroku
repo:
```
## Git
安裝 [hexo-deployer-git](https://github.com/hexojs/hexo-deployer-git)。
```
$ npm install hexo-deployer-git --save
```
修改配置。
```
deploy:
type: git
repo: <repository url>
branch: [branch]
message: [message]
```
| 參數 | 描述 |
| --- | --- |
| `repo` | 庫(Repository)地址 |
| `branch` | 分支名稱。如果您使用的是 GitHub 或 GitCafe 的話,程序會嘗試自動檢測。 |
| `message` | 自定義提交信息 (默認為 `Site updated: {{ now("YYYY-MM-DD HH:mm:ss") }}`) |
## Heroku
安裝 [hexo-deployer-heroku](https://github.com/hexojs/hexo-deployer-heroku)。
```
$ npm install hexo-deployer-heroku --save
```
修改配置。
```
deploy:
type: heroku
repo: <repository url>
message: [message]
```
| 參數 | 描述 |
| --- | --- |
| `repo` | Heroku 庫(Repository)地址 |
| `message` | 自定提交信息 (默認為 `Site updated: {{ now("YYYY-MM-DD HH:mm:ss") }}`) |
## Rsync
安裝 [hexo-deployer-rsync](https://github.com/hexojs/hexo-deployer-rsync)。
```
$ npm install hexo-deployer-rsync --save
```
修改配置。
```
deploy:
type: rsync
host: <host>
user: <user>
root: <root>
port: [port]
delete: [true|false]
verbose: [true|false]
ignore_errors: [true|false]
```
| 參數 | 描述 | 默認值 |
| --- | --- | --- |
| `host` | 遠程主機的地址 |
| `user` | 使用者名稱 |
| `root` | 遠程主機的根目錄 |
| `port` | 端口 | 22 |
| `delete` | 刪除遠程主機上的舊文件 | true |
| `verbose` | 顯示調試信息 | true |
| `ignore_errors` | 忽略錯誤 | false |
## OpenShift
安裝 [hexo-deployer-openshift](https://github.com/hexojs/hexo-deployer-openshift)。
```
$ npm install hexo-deployer-openshift --save
```
修改配置。
```
deploy:
type: openshift
repo: <repository url>
message: [message]
```
| 參數 | 描述 |
| --- | --- |
| `repo` | OpenShift 庫(Repository)地址 |
| `message` | 自定提交信息 (默認為 `Site updated: {{ now("YYYY-MM-DD HH:mm:ss") }}`) |
## FTPSync
安裝 [hexo-deployer-ftpsync](https://github.com/hexojs/hexo-deployer-ftpsync)。
```
$ npm install hexo-deployer-ftpsync --save
```
修改配置。
```
deploy:
type: ftpsync
host: <host>
user: <user>
pass: <password>
remote: [remote]
port: [port]
ignore: [ignore]
connections: [connections]
verbose: [true|false]
```
| 參數 | 描述 | 默認值 |
| --- | --- | --- |
| `host` | 遠程主機的地址 |
| `user` | 使用者名稱 |
| `pass` | 密碼 |
| `remote` | 遠程主機的根目錄 | `/` |
| `port` | 端口 | 21 |
| `ignore` | 忽略的文件或目錄 |
| `connections` | 使用的連接數 | 1 |
| `verbose` | 顯示調試信息 | false |
## 其他方法
Hexo 生成的所有文件都放在 `public` 文件夾中,您可以將它們復制到您喜歡的地方。
{% endraw %}
- 文檔
- 開始使用
- 概述
- 建站
- 配置
- 指令
- 遷移
- 基本操作
- 寫作
- Front-matter
- 標簽插件(Tag Plugins)
- 資源文件夾
- 數據文件
- 服務器
- 生成文件
- 部署
- 自定義
- 永久鏈接(Permalinks)
- 主題
- 模版
- 變量
- 輔助函數(Helpers)
- 國際化(i18n)
- 插件
- 其他
- 問題解答
- 貢獻
- API
- 核心
- 概述
- 事件
- 局部變量
- 路由
- Box
- 渲染
- 文章
- 腳手架(Scaffold)
- 主題
- 擴展
- 控制臺(Console)
- 部署器(Deployer)
- 過濾器(Filter)
- 生成器(Generator)
- 輔助函數(Helper)
- 遷移器(Migrator)
- 處理器(Processor)
- 渲染引擎(Renderer)
- 標簽插件(Tag)