mirror of
https://github.com/imfing/hextra.git
synced 2025-06-19 11:04:12 -04:00
docs: update zh-cn translations
This commit is contained in:
@ -4,32 +4,32 @@ prev: /docs/guide/shortcodes
|
||||
next: /docs/advanced
|
||||
---
|
||||
|
||||
Hugo 生成静态站点,允许多种托管方式,你可以自由选择
|
||||
本页将给出部署你的 Hextra 站点的方法
|
||||
Hugo 生成静态网站,允许灵活的托管选项。
|
||||
本页提供了在各种平台上部署 Hextra 站点的指南。
|
||||
|
||||
<!--more-->
|
||||
|
||||
|
||||
## GitHub Pages
|
||||
|
||||
[GitHub Pages](https://docs.github.com/pages) 是免费部署和托管网站的推荐方法
|
||||
[GitHub Pages](https://docs.github.com/pages) 是推荐的方式,可以免费部署和托管您的网站。
|
||||
|
||||
如果您使用以下方式引导该网站 [hextra-starter-template](https://github.com/imfing/hextra-starter-template), 它提供了开箱即用的 GitHub Actions 工作流程,有助于自动部署到 GitHub Pages
|
||||
如果您使用 [hextra-starter-template](https://github.com/imfing/hextra-starter-template) 引导站点,它已经提供了开箱即用的 GitHub Actions 工作流,帮助自动部署到 GitHub Pages。
|
||||
|
||||
{{% details title="GitHub Actions Configuration" closed="true" %}}
|
||||
{{% details title="GitHub Actions 配置" closed="true" %}}
|
||||
|
||||
以下是配置来自 [hextra-starter-template](https://github.com/imfing/hextra-starter-template) 的 Workflow 的示例:
|
||||
以下是 [hextra-starter-template](https://github.com/imfing/hextra-starter-template) 的示例配置:
|
||||
|
||||
```yaml {filename=".github/workflows/pages.yaml"}
|
||||
# 用于构建 Hugo 站点并将其部署到 GitHub Pages 的示例工作流程
|
||||
name: Deploy Hugo site to Pages
|
||||
# 用于构建和部署 Hugo 站点到 GitHub Pages 的示例工作流
|
||||
name: 部署 Hugo 站点到 Pages
|
||||
|
||||
on:
|
||||
# 由默认分支触发
|
||||
# 在推送到默认分支时运行
|
||||
push:
|
||||
branches: ["main"]
|
||||
|
||||
# 允许手动运行
|
||||
# 允许您从 Actions 选项卡手动运行此工作流
|
||||
workflow_dispatch:
|
||||
|
||||
# 设置 GITHUB_TOKEN 的权限以允许部署到 GitHub Pages
|
||||
@ -38,55 +38,55 @@ permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# 仅允许一项并发部署,跳过正在进行的运行和最新排队的运行之间排队的运行
|
||||
# 但是,不要取消正在进行的运行,因为我们希望完成这些生产部署
|
||||
# 只允许一个并发部署,跳过在运行中和最新排队之间的运行。
|
||||
# 但是,不要取消正在运行的运行,因为我们希望这些生产部署能够完成。
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
# 默认为 bash
|
||||
# 默认使用 bash
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
# 开始构建
|
||||
# 构建任务
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
HUGO_VERSION: 0.121.2
|
||||
HUGO_VERSION: 0.138.0
|
||||
steps:
|
||||
- name: Checkout
|
||||
- name: 检出
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # 获取 .GitInfo 和 .Lastmod 的所有历史记录
|
||||
fetch-depth: 0 # 获取所有历史记录以支持 .GitInfo 和 .Lastmod
|
||||
submodules: recursive
|
||||
- name: Setup Go
|
||||
- name: 设置 Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.21'
|
||||
- name: Setup Pages
|
||||
go-version: '1.22'
|
||||
- name: 设置 Pages
|
||||
id: pages
|
||||
uses: actions/configure-pages@v4
|
||||
- name: Setup Hugo
|
||||
- name: 设置 Hugo
|
||||
run: |
|
||||
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
|
||||
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
|
||||
- name: Build with Hugo
|
||||
- name: 使用 Hugo 构建
|
||||
env:
|
||||
# 最大程度地向后兼容 Hugo 模块
|
||||
# 为了最大程度地兼容 Hugo 模块
|
||||
HUGO_ENVIRONMENT: production
|
||||
HUGO_ENV: production
|
||||
run: |
|
||||
hugo \
|
||||
--gc --minify \
|
||||
--baseURL "${{ steps.pages.outputs.base_url }}/"
|
||||
- name: Upload artifact
|
||||
- name: 上传工件
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: ./public
|
||||
|
||||
# 开始部署
|
||||
# 部署任务
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
@ -94,7 +94,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
- name: 部署到 GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
```
|
||||
@ -103,13 +103,13 @@ jobs:
|
||||
|
||||
|
||||
{{< callout >}}
|
||||
在仓库设置中将 **Pages** > **Build and deployment** > **Source** 调整为 **GitHub Actions**:
|
||||
在您的仓库设置中,将 **Pages** > **Build and deployment** > **Source** 设置为 **GitHub Actions**:
|
||||

|
||||
{{< /callout >}}
|
||||
|
||||
默认情况下,上述 GitHub Actions 工作流程 `.github/workflows/pages.yaml` 假定站点部署到 `https://<USERNAME>.github.io/<REPO>/`
|
||||
默认情况下,上述 GitHub Actions 工作流 `.github/workflows/pages.yaml` 假设站点部署到 `https://<USERNAME>.github.io/<REPO>/`。
|
||||
|
||||
如需部署到 `https://<USERNAME>.github.io/` 修改参数 `--baseURL`:
|
||||
如果您部署到 `https://<USERNAME>.github.io/`,请修改 `--baseURL`:
|
||||
|
||||
```yaml {filename=".github/workflows/pages.yaml",linenos=table,linenostart=54,hl_lines=[4]}
|
||||
run: |
|
||||
@ -118,47 +118,47 @@ run: |
|
||||
--baseURL "https://${{ github.repository_owner }}.github.io/"
|
||||
```
|
||||
|
||||
如需部署到自己的域,请对应修改 `--baseURL`
|
||||
如果您部署到自己的域名,请相应地更改 `--baseURL` 值。
|
||||
|
||||
|
||||
## Cloudflare Pages
|
||||
|
||||
1. 将您的网站托管在 Git 存储库(例如 GitHub)
|
||||
2. 登录到 [Cloudflare dashboard](https://dash.cloudflare.com/) 并选择你的账户
|
||||
3. 转至在账户主页面中 **Workers & Pages** > **Create application** > **Pages** > **Connect to Git**
|
||||
4. 选择你的仓库 **Set up builds and deployments** 提供以下信息:
|
||||
1. 将您的站点源代码放入 Git 仓库(例如 GitHub)
|
||||
2. 登录 [Cloudflare 仪表板](https://dash.cloudflare.com/) 并选择您的账户
|
||||
3. 在账户主页中,选择 **Workers & Pages** > **Create application** > **Pages** > **Connect to Git**
|
||||
4. 选择仓库,并在 **Set up builds and deployments** 部分提供以下信息:
|
||||
|
||||
| Configuration | Value |
|
||||
| ----------------- | -------------------- |
|
||||
| Production branch | `main` |
|
||||
| Build command | `hugo --gc --minify` |
|
||||
| Build directory | `public` |
|
||||
| 配置项 | 值 |
|
||||
| ------------------ | -------------------- |
|
||||
| 生产分支 | `main` |
|
||||
| 构建命令 | `hugo --gc --minify` |
|
||||
| 构建目录 | `public` |
|
||||
|
||||
如需了解更多内容,见:
|
||||
- [Deploy a Hugo site](https://developers.cloudflare.com/pages/framework-guides/deploy-a-hugo-site/#deploy-with-cloudflare-pages).
|
||||
- [Language support and tools](https://developers.cloudflare.com/pages/platform/language-support-and-tools/).
|
||||
更多详情,请查看:
|
||||
- [部署 Hugo 站点](https://developers.cloudflare.com/pages/framework-guides/deploy-a-hugo-site/#deploy-with-cloudflare-pages)。
|
||||
- [语言支持和工具](https://developers.cloudflare.com/pages/platform/language-support-and-tools/)。
|
||||
|
||||
|
||||
## Netlify
|
||||
|
||||
1. 将代码推送到 Git 存储库 (如 GitHub, GitLab)
|
||||
2. [导入项目](https://app.netlify.com/start)
|
||||
3. 如果您不使用[hextra-starter-template][hextra-starter-template], 手动配置以下内容:
|
||||
- C 将构建命令配置为 `hugo --gc --minify`
|
||||
1. 将代码推送到您的 Git 仓库(GitHub、GitLab 等)
|
||||
2. [导入项目](https://app.netlify.com/start) 到 Netlify
|
||||
3. 如果您没有使用 [hextra-starter-template][hextra-starter-template],请手动配置以下内容:
|
||||
- 将构建命令配置为 `hugo --gc --minify`
|
||||
- 指定发布目录为 `public`
|
||||
- 添加环境变量 `HUGO_VERSION` 并设定为 `0.119.0`
|
||||
4. 部署
|
||||
- 添加环境变量 `HUGO_VERSION` 并设置为 `0.138.0`,或者将其设置在 `netlify.toml` 文件中
|
||||
4. 部署!
|
||||
|
||||
转至 [Hugo on Netlify](https://docs.netlify.com/integrations/frameworks/hugo/) 获得更多信息
|
||||
查看 [Netlify 上的 Hugo](https://docs.netlify.com/integrations/frameworks/hugo/) 了解更多详情。
|
||||
|
||||
|
||||
## Vercel
|
||||
|
||||
1. 将代码推送到 Git 存储库(GitHub、GitLab 等)
|
||||
2. 转至 [Vercel Dashboard](https://vercel.com/dashboard) 并导入你的 Hugo 项目
|
||||
3. 配置项目,选择 Hugo 作为 Framework Preset
|
||||
1. 将代码推送到您的 Git 仓库(GitHub、GitLab 等)
|
||||
2. 前往 [Vercel 仪表板](https://vercel.com/dashboard) 并导入您的 Hugo 项目
|
||||
3. 配置项目,选择 Hugo 作为框架预设
|
||||
4. 覆盖构建命令和安装命令:
|
||||
1. 设置构建命令为 `hugo --gc --minify`
|
||||
1. 将构建命令设置为 `hugo --gc --minify`
|
||||
2. 将安装命令设置为 `yum install golang`
|
||||
|
||||

|
||||

|
Reference in New Issue
Block a user