Hexo 提供了快速简便的部署策略。你只需要一个命令即可将你的站点部署到你的服务器。
¥Hexo provides a fast and easy deployment strategy. You only need one single command to deploy your site to your server.
$ hexo deploy |
安装与服务器/存储库提供的部署方法兼容的必要插件。
¥Install the necessary plugin(s) that is compatible with the deployment method provided by your server/repository.
部署通常通过 _config.yml 进行配置。有效配置必须具有 type
字段。例如:
¥Deployment is usually configured through _config.yml. A valid configuration must have the type
field. For example:
deploy: |
你可以使用多个部署器。Hexo 会按顺序执行每个部署器。
¥You can use multiple deployers. Hexo will execute each deployer in order.
deploy: |
更多部署插件请参考 插件 列表。
¥Refer to the Plugins list for more deployment plugins.
Git
-
¥Install hexo-deployer-git.
$ npm install hexo-deployer-git --save |
编辑 _config.yml(示例值如下所示作为注释):
¥Edit _config.yml (with example values shown below as comments):
deploy: |
选项 | 描述 | 默认 |
---|---|---|
repo |
目标存储库的 URL | |
branch |
分支名称。 | gh-pages (GitHub)coding-pages (Coding.net)master (其他) |
message |
自定义提交消息。 | Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} |
token |
用于与 repo 进行身份验证的可选令牌值。以 $ 为前缀从环境变量读取 token |
部署你的站点
hexo clean && hexo deploy
。¥Deploy your site
hexo clean && hexo deploy
.
除非你使用令牌或 ssh 密钥进行身份验证,否则系统将提示你输入目标存储库的用户名和密码。
¥You will be prompted with username and password of the target repository, unless you authenticate with a token or ssh key.
hexo-deployer-git 不存储你的用户名和密码。使用 git-credential-cache 临时存储它们。
¥hexo-deployer-git does not store your username and password. Use git-credential-cache to store them temporarily.
导航到你的存储库设置并将 “页面” 分支更改为
gh-pages
(或配置中指定的分支)。部署的站点应在 “页面” 设置上显示的链接上线。¥Navigate to your repository settings and change the “Pages” branch to
gh-pages
(or the branch specified in your config). The deployed site should be live on the link shown on the “Pages” setting.
Heroku
¥Install hexo-deployer-heroku.
$ npm install hexo-deployer-heroku --save |
编辑设置。
¥Edit settings.
deploy: |
选项 | 描述 |
---|---|
repo 、repository |
Heroku 存储库 URL |
message |
自定义提交消息(默认为 Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} ) |
Netlify
Netlify 提供持续部署(Git 触发构建)、智能全局 CDN、完整 DNS(包括自定义域)、自动 HTTPS、资源加速等等。它是一个统一的平台,可以自动化你的代码以创建高性能、易于维护的网站和 Web 应用。
¥Netlify provides continuous deployment (Git-triggered builds), an intelligent global CDN, full DNS (including custom domains), automated HTTPS, asset acceleration, and a lot more. It is a unified platform that automates your code to create high-performance, easily maintainable sites and web apps.
有两种不同的方法可以在 Netlify 上部署你的网站。最常见的方式是使用 Web UI。转到 创建新站点页面,从 GitHub,GitLab 或 Bitbucket 中选择你的项目存储库,然后按照提示进行操作。
¥There are two different ways to deploy your sites on Netlify. The most common way is to use the web UI. Go to the create a new site page, select your project repo from GitHub, GitLab, or Bitbucket, and follow the prompts.
或者,你可以使用 Netlify 的 基于节点的 CLI 工具在 Netlify 上管理和部署站点,而无需离开你的终端。
¥Alternatively, you can use Netlify’s Node based CLI tool to manage and deploy sites on Netlify without leaving your terminal.
你还可以在 README.file 中添加 部署到 Netlify 按钮,以允许其他人创建你的存储库的副本并通过一键部署到 Netlify。
¥You can also add a Deploy to Netlify Button in your README.file to allow others to create a copy of your repository and be deployed to Netlify via one click.
Rsync
¥Install hexo-deployer-rsync.
$ npm install hexo-deployer-rsync --save |
编辑设置。
¥Edit settings.
deploy: |
选项 | 描述 | 默认 |
---|---|---|
host |
远程主机地址 | |
user |
用户名 | |
root |
远程主机的根目录 | |
port |
端口 | 22 |
delete |
删除远程主机上的旧文件 | true |
verbose |
显示详细消息 | true |
ignore_errors |
忽略错误 | false |
OpenShift
hexo-deployer-openshift
已于 2022 年弃用。¥
hexo-deployer-openshift
has been deprecated in 2022.
¥Install hexo-deployer-openshift.
$ npm install hexo-deployer-openshift --save |
编辑设置。
¥Edit settings.
deploy: |
选项 | 描述 |
---|---|
repo |
OpenShift 存储库 URL |
message |
自定义提交消息(默认为 Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} ) |
FTPSync
¥Install hexo-deployer-ftpsync.
$ npm install hexo-deployer-ftpsync --save |
编辑设置。
¥Edit settings.
deploy: |
选项 | 描述 | 默认 |
---|---|---|
host |
远程主机地址 | |
user |
用户名 | |
pass |
密码 | |
remote |
远程主机的根目录 | / |
port |
端口 | 21 |
clear |
上传前从远程目录中删除所有文件和目录 | false |
verbose |
显示详细消息 | false |
SFTP
安装 hexo-deployer-sftp。通过 SFTP 部署站点,允许使用 ssh-agent 进行无密码连接。
¥Install hexo-deployer-sftp. Deploys the site via SFTP, allowing for passwordless connections using ssh-agent.
$ npm install hexo-deployer-sftp --save |
编辑设置。
¥Edit settings.
deploy: |
选项 | 描述 | 默认 |
---|---|---|
host |
远程主机地址 | |
port |
端口 | 22 |
user |
用户名 | |
pass |
密码 | |
privateKey |
ssh 私钥的路径 | |
passphrase |
私钥的可选密码 | |
agent |
ssh-agent 套接字的路径 | $SSH_AUTH_SOCK |
remotePath |
远程主机的根目录 | / |
forceUpload |
覆盖现有文件 | false |
concurrency |
同时处理的 SFTP 任务的最大数量 | 100 |
Vercel
Vercel 是一个云平台,使开发者能够托管 Jamstack 网站和 Web 服务,这些网站和服务可以即时部署、自动扩展且无需监督,并且无需任何配置。它们提供全局边缘网络、SSL 加密、资源压缩、缓存失效等。
¥Vercel is a cloud platform that enables developers to host Jamstack websites and web services that deploy instantly, scale automatically, and require no supervision, all with zero configuration. They provide a global edge network, SSL encryption, asset compression, cache invalidation, and more.
步骤 1:将构建脚本添加到你的 package.json
文件:
¥Step 1: Add a build script to your package.json
file:
{ |
步骤 2:将你的 Hexo 网站部署到 Vercel
¥Step 2: Deploy your Hexo Website to Vercel
要使用 Vercel for Git 集成 部署你的 Hexo 应用,请确保已将其推送到 Git 存储库。
¥To deploy your Hexo app with a Vercel for Git Integration, make sure it has been pushed to a Git repository.
使用 导入流程 将项目导入 Vercel。在导入过程中,你将发现为你预先配置的所有相关选项;但是,你可以选择更改这些选项中的任何一个,可以在 此处 中找到列表。
¥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.
导入项目后,所有后续推送到分支的操作都将生成 预览部署,对 生产分支(通常为 “main”)所做的所有更改都将生成 生产部署。
¥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 是一种商业托管服务,可为静态网站提供零停机部署、全球 CDN、SSL、无限带宽等。计划以按域名按量付费的方式提供。
¥Bip is a commercial hosting service that 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.
入门快速简单,因为 Bip 为 Hexo 提供了开箱即用的支持。本指南假设你已经拥有 已安装 Bip 域和 Bip CLI。
¥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:初始化你的项目目录
¥1: Initialise your project directory
$ bip init |
按照提示操作,系统会询问你要部署到哪个域。Bip 会检测到你正在使用 Hexo,并自动设置项目设置,如源文件目录。
¥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:部署你的网站
¥2: Deploy your website
$ hexo generate —deploy && bip deploy |
片刻之后,你的网站将被部署。
¥After a few moments, your website will be deployed.
R
hexo-deployer-rss3
已于 2023 年弃用。¥
hexo-deployer-rss3
has been deprecated in 2023.
R 是一种开放协议,专为 Web 3.0 时代的内容和社交网络而设计。
¥RSS3 is an open protocol designed for content and social networks in the Web 3.0 era.
-
¥Install hexo-deployer-rss3.
修改配置。
¥Modify the configuration.
deploy: # The root configuration block for all deployers |
参数 | 描述 |
---|---|
endpoint |
指向 R Hub 的链接 |
privateKey |
你的私钥,64 字节 |
ipfs/deploy |
是否部署到 IPFS |
ipfs/gateway |
IPFS API 网关 |
ipfs/api/key |
IPFS 网关相关身份验证内容 |
ipfs/api/secret |
IPFS 网关相关身份验证内容 |
生成静态文件
¥generate static files
deploy
有关部署相关的注意事项,你可以参考 我们的文档。
¥For deployment-related considerations, you can refer to Our documentation.
Edgio(以前称为 Layer0)
¥Edgio (formerly Layer0)
Edgio(以前称为 Layer0) 是一个互联网规模的平台,使团队可以轻松构建、发布、保护和加速他们的 Web 应用和 API。
¥Edgio (formerly Layer0) is an Internet-scale platform that makes it easy for teams to build, release, protect, and accelerate their web apps and APIs.
在你的 hexo 项目目录中,安装 Edgio CLI:
¥In your hexo project directory, install the Edgio CLI:
npm i -g @edgio/cli |
安装 Edgio 的 Hexo 连接器:
¥Install Hexo connector by Edgio:
edgio init --connector=@edgio/hexo |
部署
¥Deploy
edgio deploy |
或者,你可以单击下面的部署按钮来创建一个新项目:
¥Alternatively, you can click the deploy button below to create a new project:
其他方法
¥Other Methods
所有生成的文件都保存在 public
文件夹中。你可以将它们复制到任何你喜欢的地方。
¥All generated files are saved in the public
folder. You can copy them to wherever you like.