Hexo 提供了快速方便的一鍵佈署功能,讓您只需一個指令就能將網站佈署到伺服器上。
$ hexo deploy |
在開始之前,您必須先在 _config.yml
中修改設定,一個正確的部署設定中至少要有 type
欄位,例如:
deploy: |
您可同時使用多個 deployer,Hexo 會依照順序執行每個 deployer。
deploy: |
Refer to the Plugins list for more deployment plugins.
Git
$ npm install hexo-deployer-git --save |
- 修改_config.yml設定(下面的註解顯示了參數的範例)。
deploy: |
選項 | 描述 | 默認 |
---|---|---|
repo |
儲存庫(Repository)網址 | |
branch |
分支名稱。 | gh-pages (GitHub)coding-pages (Coding.net)master (others) |
message |
自定提交訊息 | Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} ) |
token |
Optional token value to authenticate with the repo. Prefix with $ to read token from environment variable |
- 上傳你的網站。執行
hexo clean && hexo deploy
。
- You will be prompted with username and password of the target repository, unless you authenticate with a token or ssh key.
- hexo-deployer-git does not store your username and password. Use git-credential-cache to store them temporarily.
- 在Github/BitBucket/Gitlab前往妳的repo設定,並將你的主要分支從
master
設為gh-pages
(或著任何你在_config.yml裡設定的名子)。現在你的網站就是你的帳號首頁。
Heroku
$ npm install hexo-deployer-heroku --save |
修改設定。
deploy: |
選項 | 描述 |
---|---|
repo |
Heroku 儲存庫(Repository)網址 |
message |
自定提交訊息 (預設是 Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} ) |
Rsync
$ npm install hexo-deployer-rsync --save |
修改設定。
deploy: |
選項 | 描述 | 預設值 |
---|---|---|
host |
遠端主機的位址 | |
user |
使用者名稱 | |
root |
遠端主機的根目錄 | |
port |
連接埠 | 22 |
delete |
刪除遠端主機上的舊檔案 | true |
verbose |
顯示除錯訊息 | true |
ignore_errors |
忽略錯誤 | false |
OpenShift
$ npm install hexo-deployer-openshift --save |
修改設定。
deploy: |
選項 | 描述 |
---|---|
repo |
OpenShift 儲存庫(Repository)網址 |
message |
自定提交訊息 (預設是 Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} ) |
FTPSync
$ npm install hexo-deployer-ftpsync --save |
修改設定。
deploy: |
選項 | 描述 | 預設值 |
---|---|---|
host |
遠端主機位址 | |
user |
使用者名稱 | |
pass |
密碼 | |
remote |
遠端主機的根目錄 | / |
port |
連接埠 | 21 |
ignore |
忽略本機或遠端的檔案 | |
connections |
連接數 | 1 |
verbose |
顯示除錯訊息 | false |
Vercel
Vercel is a cloud platform that enables developers to host Jamstack websites and web services that deploy instantly, scale automatically, and requires no supervision, all with zero configuration. They provide a global edge network, SSL encryption, asset compression, cache invalidation, and more.
Step 1: Add a build script to your package.json
file:
{ |
Step 2: Deploy your Hexo Website to Vercel
To deploy your Hexo app with a Vercel for Git Integration, make sure it has been pushed to a Git repository.
Import the project into Vercel using the Import Flow. During the import, you will find all relevant options preconfigured for you; however, you can choose to change any of these options, a list of which can be found here.
After your project has been imported, all subsequent pushes to branches will generate Preview Deployments, and all changes made to the Production Branch (commonly “main”) will result in a Production Deployment.
Alternatively, you can click the deploy button below to create a new project:
Bip
Bip is a commercial hosting service which provides zero downtime deployment, a global CDN, SSL, unlimited bandwidth and more for static websites. Plans are available on a pay as you go, per domain basis.
Getting started is quick and easy, as Bip provides out the box support for Hexo. This guide assumes you already have a Bip domain and Bip CLI installed.
1: Initialise your project directory
$ bip init |
Follow the prompts, where you’ll be asked which domain you’d like to deploy to. Bip will detect that you’re using Hexo, and set project settings like the source file directory automatically.
2: Deploy your website
$ hexo generate —deploy && bip deploy |
After a few moments, your website will be deployed.
RSS3
RSS3 是一個為 Web 3.0 時代的內容和社交網路設計的開放協議。
修改配置。
deploy: # 所有部署器的根配置塊 |
參數 | 描述 |
---|---|
endpoint |
一個 RSS3 Hub 的鏈接 |
privateKey |
您的私鑰, 64 字節 |
ipfs/deploy |
是否部署到 IPFS 上 |
ipfs/gateway |
IPFS API 網關 |
ipfs/api/key |
IPFS 網關相關的驗證內容 |
ipfs/api/secret |
IPFS 網關相關的驗證內容 |
生成靜態文件
部署
關於具體部署相關的註意事項,您可以參閱 我們的文檔 。
其他方法
Hexo 產生的所有檔案都放在 public
資料夾,您可以將它們拷貝到您喜歡的地方。