Skip to content

Commit 9605464

Browse files
LisaFCdeining
authored andcommitted
Few edits, slight reorganization
1 parent fa2e362 commit 9605464

File tree

1 file changed

+77
-81
lines changed
  • userguide/content/en/docs/deployment

1 file changed

+77
-81
lines changed

userguide/content/en/docs/deployment/_index.md

Lines changed: 77 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,24 @@ If you have an existing deployment you can view and update the relevant informat
7575

7676
## Deployment on GitHub Pages
7777

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.
7981

8082
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).
8183

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):
84+
{{% alert title="Correct baseURL setting" color="primary" %}}
85+
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):
8389

8490
```console
8591
$ git checkout -b gh-pages
8692
Switched to a new branch 'gh-pages'
8793
```
8894
89-
1. Then push this local branch to your repo:
95+
1. Push this local branch to your repo:
9096
9197
```console
9298
$ 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
95101
branch 'gh-pages' set up to track 'origin/gh-pages'.
96102
```
97103
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:
99105
100106
```console
101107
$ git checkout main
102108
Switched to branch 'main'
103109
104110
```
105111
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:
112115
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+
116121
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:
118123
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
142147
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
148153
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'
155160
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
158163
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+
```
165170
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:
167172
168-
```console
169-
$ git add .github/workflows/deploy-github-pages.yml
170-
$ git commit -m "Adding workflow file for site deployment"
171-
$ git push origin
172-
```
173+
```console
174+
$ git add .github/workflows/deploy-github-pages.yml
175+
$ git commit -m "Adding workflow file for site deployment"
176+
$ git push origin
177+
```
173178
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:
175-
176-
```
177-
URL Repo Page settings: https://github.com/<username>/<repository_name>/settings/pages
178-
```
179+
1. In your browser, make sure you are logged into your GitHub account. In your repo **Settings**, select **Pages**.
179180
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.
181182
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.
183184
184-
3. From the **folder** dropdown, select `/(root)` as root directory.
185+
3. From the **folder** dropdown, select **/(root)** as root directory.
185186
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.
187188

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.
189190

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:
191192

192193
```
193194
URL 'Repo actions': https://github.com/<username>/<repository_name>/actions
194195
```
195196
196-
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:
197198
198199
```
199200
URL 'Repo deployments': https://github.com/<username>/<repository_name>/deployments/
200201
```
201202
202-
{{% alert title="Correct baseURL setting" color="primary" %}}
203-
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.
204-
{{% /alert %}}
205-
206-
{{% alert title="Further reading" color="primary" %}}
207-
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.
208204
209205
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).
210-
{{% /alert %}}
206+
211207
212208
## Deployment with Amazon S3 + Amazon CloudFront
213209

0 commit comments

Comments
 (0)