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
+77-81Lines changed: 77 additions & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,18 +75,24 @@ If you have an existing deployment you can view and update the relevant informat
75
75
76
76
## Deployment on GitHub Pages
77
77
78
-
If your repo is hosted on [GitHub](https://github.com), the simplest option to serve your site is deployment on [GitHub pages](https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages). There are 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) via GitHub actions and the [marketplace for actions](https://github.com/marketplace/actions) has a lot of useful tools for spell and link checking, deploy preview and more. Using your existing GitHub account, you can start with the free plan of GitHub Pages for publicly available repositories, with premium tiers available for business use cases.
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.
79
81
80
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).
81
83
82
-
1. With GitHub Pages, a site is published to the branch `gh-pages` and served from there by default. Therefore, you have to create this branch first, either in the GitHub web interface or via command line (at the root of your local repo clone):
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):
83
89
84
90
```console
85
91
$ git checkout -b gh-pages
86
92
Switched to a new branch 'gh-pages'
87
93
```
88
94
89
-
1. Then push this local branch to your repo:
95
+
1. Push this local branch to your repo:
90
96
91
97
```console
92
98
$ git push --set-upstream origin gh-pages
@@ -95,119 +101,109 @@ Before deploying on GitHub Pages, make sure that you've pushed your site source
95
101
branch 'gh-pages' set up to track 'origin/gh-pages'.
96
102
```
97
103
98
-
1. Now switch back to the `main` (or `work`) branch of your repo:
104
+
1. Switch back to the `main` (or `work`) branch of your repo:
99
105
100
106
```console
101
107
$ git checkout main
102
108
Switched to branch 'main'
103
109
104
110
```
105
111
106
-
1. At the root of your local repo, create a new empty workflow file `.github/workflows/deploy-github-pages.yml`:
107
-
108
-
```console
109
-
$ mkdir -p .github/workflows
110
-
$ touch .github/workflows/deploy-github-pages.yml
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:
112
115
113
-
{{% alert title="Workflow setup with docsy example site" color="primary" %}}
114
-
Please note that a such a deployment [workflow file](https://github.com/google/docsy-example/blob/master/.github/workflows/deploy-github-pages.yml) was added to the docsy-example site recently. 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/), please check your repo for this file, it might be part of your site repo already.
115
-
{{% /alert %}}
116
+
```console
117
+
$ mkdir -p .github/workflows
118
+
$ touch .github/workflows/deploy-github-pages.yml
119
+
```
120
+
116
121
117
-
1. Open the newly created, empty workflow file in an editor of your choice, paste in the code below and save the file:
122
+
1. Open the file in an editor of your choice, paste in the code below, and save the file:
118
123
119
-
```yaml
120
-
name: Deployment to GitHub Pages
121
-
122
-
on:
123
-
workflow_dispatch:
124
-
push:
125
-
branches:
126
-
- main # <-- specify the branch you want to deploy from
127
-
pull_request:
128
-
129
-
env:
130
-
REPO_NAME: ${{ github.event.repository.name }}
131
-
REPO_OWNER: ${{ github.repository_owner }}
132
-
133
-
jobs:
134
-
deploy:
135
-
runs-on: ubuntu-22.04
136
-
concurrency:
137
-
group: ${{ github.workflow }}-${{ github.ref }}
138
-
steps:
139
-
- uses: actions/checkout@v3
140
-
with:
141
-
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
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@v3
145
+
with:
146
+
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
142
147
143
-
- name: Setup Hugo
144
-
uses: peaceiris/actions-hugo@v2
145
-
with:
146
-
hugo-version: '0.110.0'
147
-
extended: true
148
+
- name: Setup Hugo
149
+
uses: peaceiris/actions-hugo@v2
150
+
with:
151
+
hugo-version: '0.110.0'
152
+
extended: true
148
153
149
-
- name: Setup Node
150
-
uses: actions/setup-node@v3
151
-
with:
152
-
node-version: '18'
153
-
cache: 'npm'
154
-
cache-dependency-path: '**/package-lock.json'
154
+
- name: Setup Node
155
+
uses: actions/setup-node@v3
156
+
with:
157
+
node-version: '18'
158
+
cache: 'npm'
159
+
cache-dependency-path: '**/package-lock.json'
155
160
156
-
- run: npm ci
157
-
- run: hugo --baseURL https://${REPO_OWNER}.github.io/${REPO_NAME} --minify
161
+
- run: npm ci
162
+
- run: hugo --baseURL https://${REPO_OWNER}.github.io/${REPO_NAME} --minify
158
163
159
-
- name: Deploy
160
-
uses: peaceiris/actions-gh-pages@v3
161
-
if: ${{ github.ref == 'refs/heads/main' }} # <-- specify same branch as above here
162
-
with:
163
-
github_token: ${{ secrets.GITHUB_TOKEN }}
164
-
```
164
+
- name: Deploy
165
+
uses: peaceiris/actions-gh-pages@v3
166
+
if: ${{ github.ref == 'refs/heads/main' }} # <-- specify same branch as above here
167
+
with:
168
+
github_token: ${{ secrets.GITHUB_TOKEN }}
169
+
```
165
170
166
-
1. Afterwards, add the file to the staging area, commit your change and push the change to your remote GitHub repo:
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
+
```
173
178
174
-
1. In your browser, make sure you are logged into your GitHub account. Then visit the subsection `Pages` in your repo `Settings`. You may use the URL below to directly jump to this subsection:
1. In your browser, make sure you are logged into your GitHub account. In your repo **Settings**, select **Pages**.
179
180
180
-
1. Under `Build and deployment`, select `Deploy from a branch` in the **source** dropdown.
181
+
1. Under **Build and deployment**, select **Deploy from a branch** in the **source** dropdown.
181
182
182
-
2. From the **branch** dropdown, select `gh-pages` as branch where the site is built from.
183
+
2. From the **branch** dropdown, select **gh-page** as branch where the site is built from.
183
184
184
-
3. From the **folder** dropdown, select `/(root)` as root directory.
185
+
3. From the **folder** dropdown, select **/(root)** as root directory.
185
186
186
-
1. That's it! Your deployment workflow for your site is configured!
187
+
That's it! Your deployment workflow for your site is configured.
187
188
188
-
Any future push to the branch specified in your workflow file will now trigger the action workflow defined in this file. Additionally, you are able to trigger the deployment manually inside your web browser via the GitHub web UI.
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.
189
190
190
-
Once you pushed to your repo, you can see the progress of the triggered workflow in the `Actions` tab of the the GitHub web UI:
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, you will find it at the right of your repo main view (below `Releases` and `Packages`). When clicking on the newly created environment, a list of deployments is presented to you:
197
+
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:
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.
In the hugo docs, you can find a chapter [Hosting on GitHub]( https://gohugo.io/hosting-and-deployment/hosting-on-github/).
203
+
You can find out more in [Hosting on GitHub]( https://gohugo.io/hosting-and-deployment/hosting-on-github/) in the Hugo documentation.
208
204
209
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).
0 commit comments