如果您没有 Netlify 帐户,可以注册一个。
进入管理界面后,您可以从 Git 提供商(GitHub、GitLab 或 Bitbucket)添加站点。在此过程结束时,您可以选择项目的部署设置:
zola build
将变量中的版本号替换为您要使用的版本)public
发布目录:目录所在的路径ZOLA_VERSION
例如0.13.0
作为值使用此设置,您的站点应该在每次提交 master 时自动部署。对于,您可以使用GitHub 存储库中的ZOLA_VERSION
任何标记版本。release
Netlify 将自动获取标记版本并使用它来构建您的站点。
但是,如果您想使用 Netlify 提供的所有内容,您还应该发布用于拉取请求的临时站点。
这是通过在您的存储库中添加以下netlify.toml
文件并在管理界面中删除构建命令/发布目录来完成的。
[build]
# This assumes that the Zola site is in a docs folder. If it isn't, you don't need
# to have a `base` variable but you do need the `publish` and `command` variables.
base = "docs"
publish = "docs/public"
command = "zola build"
[build.environment]
# Set the version name that you want to use and Netlify will automatically use it.
ZOLA_VERSION = "0.13.0"
# The magic for deploying previews of branches.
# We need to override the base url with whatever url Netlify assigns to our
# preview site. We do this using the Netlify environment variable
# `$DEPLOY_PRIME_URL`.
[context.deploy-preview]
command = "zola build --base-url $DEPLOY_PRIME_URL"
如果您更愿意使用未标记版本的 Zola 版本(例如,在从源代码构建 Zola 并进行修改之后),那么您将需要手动将文件夹部署到 Netlify public
。您可以通过 Netlify 的 Web GUI 或命令行执行此操作。
对于命令行手动部署,请执行以下步骤:
Personal Access Token
的设置部分生成一个。zola build
.public
目录的 zip 文件夹。curl
以下命令,填写 PERSONAL_ACCESS_TOKEN_FROM_STEP_1、FILE_NAME.zip 和 SITE_NAME 的值。curl -H "Content-Type: application/zip" \
-H "Authorization: Bearer PERSONAL_ACCESS_TOKEN_FROM_STEP_1" \
--data-binary "@FILE_NAME.zip" \
https://api.netlify.com/api/v1/sites/SITE_NAME.netlify.com/deploys