You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: userguide/content/en/docs/deployment/_index.md
+142-7Lines changed: 142 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,9 +45,11 @@ Then follow the instructions in [Host on Netlify](https://gohugo.io/hosting-and-
45
45
* If you are using Docsy as a [Hugo module](/docs/get-started/docsy-as-module/) or NPM package, you can just specify `hugo`.
46
46
3. Click **Show advanced**.
47
47
4. In the **Advanced build settings** section, click **New variable**.
48
-
5. Specify `HUGO_VERSION` as the **Key** for the new variable, and set its **Value** to the latest version of Hugo (minimum required version: `0.110.0`).
49
-
6. In the **Advanced build settings** section, click **New variable** again.
50
-
7. Specify `GO_VERSION` as the **Key** for the new variable, and set its **Value** to the latest version of Go (minimum recommended version: `1.18`).
48
+
5. Specify `NODE_VERSION` as the **Key** for the new variable, and set its **Value** to the [latest LTS version](https://nodejs.org/en/download/) of node.js (minimum recommended version: `v20.x`).
49
+
6. In the **Advanced build settings** section, click **New variable**.
50
+
7. Specify `HUGO_VERSION` as the **Key** for the new variable, and set its **Value** to the [latest version](https://github.com/gohugoio/hugo/releases) of Hugo (minimum recommended version: `0.125.4`).
51
+
8. In the **Advanced build settings** section, click **New variable** again.
52
+
9. Specify `GO_VERSION` as the **Key** for the new variable, and set its **Value** to the [latest version](https://go.dev/dl/) of Go (minimum recommended version: `1.21`).
51
53
52
54
If you don't want your site to be indexed by search engines, you can add an environment flag to your build command to specify a non-`production` environment, as described in [Build environments and indexing](#build-environments-and-indexing).
53
55
1. Click **Deploy site**.
@@ -59,9 +61,9 @@ For example, if you want to use a version of `postcss-cli` later than version 8.
59
61
60
62
```
61
63
"devDependencies": {
62
-
"autoprefixer": "^9.8.8",
63
-
"postcss-cli": "^8.0.0",
64
-
"postcss": "^8.0.0"
64
+
"autoprefixer": "^10.4.19",
65
+
"postcss-cli": "^11.0.0",
66
+
"postcss": "^8.4.38"
65
67
}
66
68
```
67
69
@@ -71,6 +73,138 @@ Alternatively, you can follow the same instructions but specify your **Deploy se
71
73
72
74
If you have an existing deployment you can view and update the relevant information by selecting the site from your list of sites in Netlify, then clicking **Site settings** - **Build and deploy**. Ensure that **Ubuntu Focal 20.04** is selected in the **Build image selection** section - if you're creating a new deployment this is used by default. You need to use this image to run the extended version of Hugo.
73
75
76
+
## Deployment on GitHub Pages
77
+
78
+
If your repo is hosted on [GitHub](https://github.com), a simple option is to serve your site with [GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages). GitHub Pages lets you create project, user, and organization sites; for a project site, your site URL will be `http(s)://<username>.github.io/<repository_name>`, custom domains are also supported. GitHub Pages come with [continuous deployment](https://docs.github.com/en/actions/deployment/about-deployments/about-continuous-deployment) using GitHub actions, while the [marketplace for actions](https://github.com/marketplace/actions) has useful tools for spell and link checking, deploy previews, and more. Using your existing GitHub account, you can start by using the free plan for publicly available repositories, with premium tiers available for business use cases.
79
+
80
+
The Docsy example site repo provides a [workflow file](https://github.com/google/docsy-example/blob/master/.github/workflows/deploy-github-pages.yml) that you can use when deploying to GitHub Pages. If you used the example site as template for your new site as described [here](https://www.docsy.dev/docs/get-started/docsy-as-module/example-site-as-template/), you may already have this file in your repo, if not the instructions below show you how to create your own workflow file.
81
+
82
+
Before deploying on GitHub Pages, make sure that you've pushed your site source to your chosen GitHub repo, following any setup instructions in [Using the theme](/docs/get-started/docsy-as-module).
Make sure to correctly set your site's `baseURL`, either via hugo's `--baseURL '…'` command line parameter or inside your your `hugo.toml`/`hugo.yaml`/`hugo.json` configuration file. When deploying to GitHub pages your `baseURL` needs to be set to `https://<USERNAME>.github.io/<repository_name>`, otherwise your site layout will be broken.
86
+
{{% /alert %}}
87
+
88
+
1. With GitHub Pages, a site is published to the branch `gh-pages` and served from there by default. You must create this branch first, either in the GitHub web interface or via command line (at the root of your local repo clone):
89
+
90
+
```console
91
+
$ git checkout -b gh-pages
92
+
Switched to a new branch 'gh-pages'
93
+
```
94
+
95
+
1. Push this local branch to your repo:
96
+
97
+
```console
98
+
$ git push --set-upstream origin gh-pages
99
+
details omitted …
100
+
* [new branch] new -> new
101
+
branch 'gh-pages' set up to track 'origin/gh-pages'.
102
+
```
103
+
104
+
1. Switch back to the `main` (or `work`) branch of your repo:
105
+
106
+
```console
107
+
$ git checkout main
108
+
Switched to branch 'main'
109
+
110
+
```
111
+
112
+
1. Check if you already have the workflow file `.github/workflows/deploy-github-pages.yml` in your repo. If this file doesn't exist, do the following:
113
+
114
+
1. Create a new empty workflow file from the root of your repo, as follows:
115
+
116
+
```console
117
+
$ mkdir -p .github/workflows
118
+
$ touch .github/workflows/deploy-github-pages.yml
119
+
```
120
+
121
+
122
+
1. Open the file in an editor of your choice, paste in the code below, and save the file:
123
+
124
+
```yaml
125
+
name: Deployment to GitHub Pages
126
+
127
+
on:
128
+
workflow_dispatch:
129
+
push:
130
+
branches:
131
+
- main # <-- specify the branch you want to deploy from
132
+
pull_request:
133
+
134
+
env:
135
+
REPO_NAME: ${{ github.event.repository.name }}
136
+
REPO_OWNER: ${{ github.repository_owner }}
137
+
138
+
jobs:
139
+
deploy:
140
+
runs-on: ubuntu-22.04
141
+
concurrency:
142
+
group: ${{ github.workflow }}-${{ github.ref }}
143
+
steps:
144
+
- uses: actions/checkout@v4
145
+
with:
146
+
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
147
+
148
+
- name: Setup Hugo
149
+
uses: peaceiris/actions-hugo@v3
150
+
with:
151
+
hugo-version: '0.125.5'
152
+
extended: true
153
+
154
+
- name: Setup Node
155
+
uses: actions/setup-node@v4
156
+
with:
157
+
node-version: '20'
158
+
cache: 'npm'
159
+
cache-dependency-path: '**/package-lock.json'
160
+
161
+
- run: npm ci
162
+
- run: hugo --baseURL https://${REPO_OWNER}.github.io/${REPO_NAME} --minify
163
+
164
+
- name: Deploy
165
+
uses: peaceiris/actions-gh-pages@v4
166
+
if: ${{ github.ref == 'refs/heads/main' }} # <-- specify same branch as above here
167
+
with:
168
+
github_token: ${{ secrets.GITHUB_TOKEN }}
169
+
```
170
+
171
+
1. Add the file to the staging area, commit your change and push the change to your remote GitHub repo:
$ git commit -m "Adding workflow file for site deployment"
176
+
$ git push origin
177
+
```
178
+
179
+
1. In your browser, make sure you are logged into your GitHub account. In your repo **Settings**, select **Pages**.
180
+
181
+
1. Under **Build and deployment**, select **Deploy from a branch** in the **source** dropdown.
182
+
183
+
2. From the **branch** dropdown, select **gh-page** as branch where the site is built from.
184
+
185
+
3. From the **folder** dropdown, select **/(root)** as root directory.
186
+
187
+
That's it! Your deployment workflow for your site is configured.
188
+
189
+
Any future push to the branch specified in your workflow file will now trigger the action workflow defined in the workflow file. Additionally, you can trigger the deployment manually by using GitHub web UI.
190
+
191
+
Once you push to your repo, you can see the progress of the triggered workflow in the **Actions** tab of the the GitHub web UI:
After the first successful deployment, a new environment `github-pages` is added to your repo. This is shown at the right of your repo main view (below **Releases** and **Packages**). When you click on this environment, a list of deployments is displayed:
You can find out more in [Hosting on GitHub]( https://gohugo.io/hosting-and-deployment/hosting-on-github/) in the Hugo documentation.
204
+
205
+
For advanced use cases, the [`hugo-action`](https://github.com/peaceiris/actions-hugo) used inside the workflow file has more configuration options, which are well [documented](https://github.com/marketplace/actions/hugo-setup).
206
+
207
+
74
208
## Deployment with Amazon S3 + Amazon CloudFront
75
209
76
210
There are several options for publishing your web site using [Amazon Web Services](https://aws.amazon.com), as described in this [blog post](https://adrianhall.github.io/cloud/2019/01/31/which-aws-service-for-hosting/). This section describes the most basic option, deploying your site using an S3 bucket and activating the CloudFront CDN (content delivery network) to speed up the delivery of your deployed contents.
@@ -117,7 +251,8 @@ deployment:
117
251
}
118
252
]
119
253
}
120
-
}{{< /tab >}}
254
+
}
255
+
{{< /tab >}}
121
256
{{< /tabpane >}}
122
257
123
258
1. Run the command `hugo --gc --minify` to render the site's assets into the `public/` directory of your Hugo build environment.
0 commit comments