部署按钮

最近更新时间:2026-01-09 17:47:32

我的收藏
本小节将介绍如何在 GitHub 仓库中添加一键部署按钮,让用户能够快速将您的模板部署到 EdgeOne Pages。

部署按钮

Pages 部署按钮如下所示:

使用 EdgeOne Pages 部署


当用户点击此按钮时,他们将被引导至 Pages,并预先配置您的仓库作为部署源。

如何添加部署按钮

将以下 Markdown 代码添加到您仓库的 README.md 文件中:
[![使用 EdgeOne Pages 部署](https://cdnstatic.tencentcs.com/edgeone/pages/deploy.svg)](https://console.cloud.tencent.com/edgeone/pages/new?repository-url=YOUR_REPO_URL)
YOUR_REPO_URL 替换为您的 GitHub 仓库 URL,支持子路径。例如:
[![使用 EdgeOne Pages 部署](https://cdnstatic.tencentcs.com/edgeone/pages/deploy.svg)](https://console.cloud.tencent.com/edgeone/pages/new?repository-url=https%3A%2F%2Fgithub.com%2FTencentEdgeOne%2Fpages-templates%2Ftree%2Fmain%2Fexamples%2Fvue-template)

URL Search 参数

部署按钮 URL 支持以下 Search 参数:
Search 参数名称
描述
template
通过 Pages 官方模板来部署的模板名称
repository-name
GitHub 仓库名称
repository-url
通过其他 GitHub 仓库来部署的仓库地址
project-name
项目名称
build-command
构建命令
install-command
安装命令
output-directory
构建后产物的输出目录
root-directory
构建根目录
env
仓库必要的环境变量,如需多个可用英文逗号连接。例如:KEY1,KEY2,KEY3
env-description
跟环境变量相关的描述
env-link
跟环境变量相关的链接
注意:
参数值需使用 encodeURIComponent() 编码后再拼接进 URL,例如 build-command=npm%20run%20build

示例

对于公共 GitHub 仓库:
[![使用 EdgeOne Pages 部署](https://cdnstatic.tencentcs.com/edgeone/pages/deploy.svg)](https://console.cloud.tencent.com/edgeone/pages/new?repository-url=https%3A%2F%2Fgithub.com%2Fusername%2Frepository)
对于特定分支:
[![使用 EdgeOne Pages 部署](https://cdnstatic.tencentcs.com/edgeone/pages/deploy.svg)](https://console.cloud.tencent.com/edgeone/pages/new?repository-url=https%3A%2F%2Fgithub.com%2Fusername%2Frepository%2Ftree%2Fbranch-name)
如何使用 URL Search 参数:
[![使用 EdgeOne Pages 部署](https://cdnstatic.tencentcs.com/edgeone/pages/deploy.svg)](https://console.cloud.tencent.com/edgeone/pages/new?repository-url=https%3A%2F%2Fgithub.com%2FTencentEdgeOne%2Fpages-templates%2Ftree%2Fmain%2Fexamples%2Fvue-template&output-directory=.%2Fdist&install-command=npm%20install&build-command=npm%20run%20build)

用户体验

当用户点击部署按钮时:
1. 页面将被重定向到 Pages 控制台。
2. GitHub 仓库将被作为默认的部署源。
3. 支持调整项目的配置项。
4. 单击立即创建后,项目就会被部署至 Pages。
这为想要快速尝试或部署您的模板的用户提供了无缝的体验。

更多配置

参考 edgeone.json,您可以自定义项目的构建命令(buildCommand)、依赖安装命令(installCommand)以及输出目录(outputDirectory)。建议根据项目实际情况配置这些参数,以确保其他人能够正确构建和部署您的项目。