Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'

This commit is contained in:
Bjørn Erik Pedersen
2023-12-04 15:24:01 +01:00
810 changed files with 24147 additions and 7766 deletions

View File

@@ -2,7 +2,7 @@
title: Hosting and deployment
linkTitle: Overview
description: Site builds, automated deployments, and popular hosting solutions.
categories: [hosting and deployment]
categories: []
keywords: []
menu:
docs:

View File

@@ -2,12 +2,12 @@
title: Deploy with Rclone
description: If you have access to your web host with SFTP/FTP/SSH/HTTP(DAV), you can use rclone to incrementally deploy your entire Hugo website.
categories: [hosting and deployment]
keywords: [rclone,sftp,deployment]
keywords: [deployment,rclone,sftp]
menu:
docs:
parent: hosting-and-deployment
aliases: [/tutorials/deployment-with-rclone/]
toc: true
aliases: [/tutorials/deployment-with-rclone/]
---
## Assumptions

View File

@@ -2,12 +2,12 @@
title: Deploy with Rsync
description: If you have access to your web host with SSH, you can use a simple rsync one-liner to incrementally deploy your entire Hugo website.
categories: [hosting and deployment]
keywords: [rsync,deployment]
keywords: [deployment,rsync]
menu:
docs:
parent: hosting-and-deployment
aliases: [/tutorials/deployment-with-rsync/]
toc: true
aliases: [/tutorials/deployment-with-rsync/]
---
## Assumptions
@@ -30,7 +30,7 @@ To make logging in to your server more secure and less interactive, you can uplo
First, install the ssh client. On Debian distributions, use the following command:
{{< code file="install-openssh.sh" >}}
{{< code file=install-openssh.sh >}}
sudo apt-get install openssh-client
{{< /code >}}
@@ -85,7 +85,7 @@ Create a new script called `deploy` the root of your Hugo tree:
Add the following content. Replace the `USER`, `HOST`, and `DIR` values with your own values:
```bash
```sh
#!/bin/sh
USER=my-user
HOST=my-server.com
@@ -136,4 +136,4 @@ sent 9,550 bytes received 1,708 bytes 7,505.33 bytes/sec
total size is 966,557 speedup is 85.86
```
You can incorporate other proprocessing tasks into this deployment script as well.
You can incorporate other processing tasks into this deployment script as well.

View File

@@ -2,7 +2,7 @@
title: Host on 21YunBox
description: Host your Hugo site with 21YunBox's blazing fast Chinese CDN, fully-managed SSL and auto deploys from Gitee.
categories: [hosting and deployment]
keywords: [21yunbox,hosting,deployment]
keywords: [hosting,21yunbox]
menu:
docs:
parent: hosting-and-deployment

View File

@@ -2,7 +2,7 @@
title: Host on AWS Amplify
description: Develop and deploy a cloud-powered web app with AWS Amplify.
categories: [hosting and deployment]
keywords: [amplify,hosting,deployment]
keywords: [hosting,amplify]
menu:
docs:
parent: hosting-and-deployment

View File

@@ -2,7 +2,7 @@
title: Host on Azure Static Web Apps
description: Publish a Hugo site to Azure Static Web Apps.
categories: [hosting and deployment]
keywords: [hosting,Azure Static Web Apps]
keywords: [hosting,azure]
menu:
docs:
parent: hosting-and-deployment

View File

@@ -2,6 +2,7 @@
title: Host on Cloudflare Pages
description: Cloudflare Pages can host your Hugo site with CDN, continuous deployment, 1-click HTTPS, an admin GUI, and its own environment variables.
categories: [hosting and deployment]
keywords: [hosting,cloudflare]
menu:
docs:
parent: hosting-and-deployment

View File

@@ -1,6 +1,6 @@
---
title: Host on Firebase
description: You can use Firebase's free tier to host your static website; this also gives you access to Firebase's NOSQL API.
description: You can use Firebase's free tier to host your static website; this also gives you access to Firebase's NoSQL API.
categories: [hosting and deployment]
keywords: [hosting,firebase]
menu:
@@ -18,20 +18,19 @@ toc: true
Go to the [Firebase console][console] and create a new project (unless you already have a project). You will need to globally install `firebase-tools` (node.js):
```txt
```sh
npm install -g firebase-tools
```
Log in to Firebase (setup on your local machine) using `firebase login`, which opens a browser where you can select your account. Use `firebase logout` in case you are already logged in but to the wrong account.
```txt
```sh
firebase login
```
In the root of your Hugo project, initialize the Firebase project with the `firebase init` command:
```txt
```sh
firebase init
```
@@ -78,7 +77,7 @@ Don't forget to update your static pages before push!
To deploy your Hugo site, execute the `firebase deploy` command, and your site will be up in no time:
```txt
```sh
hugo && firebase deploy
```
@@ -86,7 +85,7 @@ hugo && firebase deploy
You can generate a deploy token using
```txt
```sh
firebase login:ci
```
@@ -98,7 +97,7 @@ This is a private secret and it should not appear in a public repository. Make s
You can then add a step in your build to do the deployment using the token:
```txt
```sh
firebase deploy --token $FIREBASE_DEPLOY_TOKEN
```

View File

@@ -2,7 +2,7 @@
title: Host on GitHub Pages
description: Deploy Hugo as a GitHub Pages project or personal/organizational site and automate the whole process with GitHub Actions
categories: [hosting and deployment]
keywords: [github,git,deployment,hosting]
keywords: [hosting,github]
menu:
docs:
parent: hosting-and-deployment
@@ -32,7 +32,6 @@ See the [GitHub Pages documentation] to understand the requirements for reposito
[GitHub Pages documentation]: https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages#types-of-github-pages-sites
{{% /note %}}
[GitHub Pages documentation]: https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages#types-of-github-pages-sites
## Procedure
@@ -44,7 +43,7 @@ Step 2
: Push your local repository to GitHub.
Step 3
: Visit your GitHub repository. From the main menu choose **Settings**&nbsp;>&nbsp;**Pages**. In then center of your screen you will see this:
: Visit your GitHub repository. From the main menu choose **Settings**&nbsp;>&nbsp;**Pages**. In the center of your screen you will see this:
![screen capture](gh-pages-1.png)
{style="max-width: 280px"}
@@ -65,7 +64,7 @@ Step 5
Step 6
: Copy and paste the YAML below into the file you created. Change the branch name and Hugo version as needed.
{{< code file=".github/workflows/hugo.yaml" >}}
{{< code file=.github/workflows/hugo.yaml copy=true >}}
# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo site to Pages
@@ -100,7 +99,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.115.4
HUGO_VERSION: 0.120.2
steps:
- name: Install Hugo CLI
run: |
@@ -109,7 +108,7 @@ jobs:
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
@@ -129,7 +128,7 @@ jobs:
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v2
with:
path: ./public

View File

@@ -2,7 +2,7 @@
title: Host on GitLab Pages
description: GitLab makes it easy to build, deploy, and host your Hugo website via their free GitLab Pages service, which provides native support for Hugo.
categories: [hosting and deployment]
keywords: [hosting,deployment,git,gitlab]
keywords: [hosting,gitlab]
menu:
docs:
parent: hosting-and-deployment
@@ -25,7 +25,7 @@ The `baseURL` in your [site configuration](/getting-started/configuration/) must
Define your [CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) jobs by creating a `.gitlab-ci.yml` file in the root of your project.
{{< code file=".gitlab-ci.yml" >}}
{{< code file=.gitlab-ci.yml copy=true >}}
variables:
DART_SASS_VERSION: 1.64.1
HUGO_VERSION: 0.115.4
@@ -74,7 +74,7 @@ pages:
Next, create a new repository on GitLab. It is *not* necessary to make the repository public. In addition, you might want to add `/public` to your .gitignore file, as there is no need to push compiled assets to GitLab or keep your output website in version control.
```bash
```sh
# initialize new git repository
git init

View File

@@ -2,7 +2,7 @@
title: Host on KeyCDN
description: "Accelerate your Hugo site globally with a KeyCDN integration. This tutorial shows you how to set up your static site as a GitLab page behind a KeyCDN pull zone."
categories: [hosting and deployment]
keywords: [keycdn,hosting,deployment,cdn]
keywords: [hosting,keycdn]
menu:
docs:
parent: hosting-and-deployment
@@ -58,8 +58,8 @@ pages:
- public
only:
- master
```
Using this integration method, you will have to specify the Zone ID and your [KeyCDN API](https://www.keycdn.com/api) key as secret variables. To do this, navigate to the top-left menu bar in GitLab and select Projects. Then, select your project and click on the Settings page. Finally, select Pipelines from the sub-menu and scroll down to the Secret Variable section.
The Secret Variable for your Zone ID should look similar to:
@@ -76,7 +76,7 @@ The Zone ID and API key are used to purge your zone its not strictly need
Now its time to push the newly created repository to GitLab:
```bash
```sh
git remote add origin git@gitlab.com:youruser/ci-example.git
git push -u origin master
```

View File

@@ -2,7 +2,7 @@
title: Host on Netlify
description: Netlify can host your Hugo site with CDN, continuous deployment, 1-click HTTPS, an admin GUI, and its own CLI.
categories: [hosting and deployment]
keywords: [netlify,hosting,deployment]
keywords: [hosting,netlify]
menu:
docs:
parent: hosting-and-deployment
@@ -19,7 +19,7 @@ toc: true
## Create a Netlify account
Go to [app.netlify.com] and select your preferred signup method. This will likely be a hosted Git provider, although you also have the option to sign up with an email address.
Go to [app.netlify.com] and select your preferred sign up method. This will likely be a hosted Git provider, although you also have the option to sign up with an email address.
The following examples use GitHub, but other git providers will follow a similar process.
@@ -55,21 +55,21 @@ You can [set Hugo version](https://www.netlify.com/blog/2017/04/11/netlify-plus-
For production:
{{< code file="netlify.toml" >}}
{{< code file=netlify.toml >}}
[context.production.environment]
HUGO_VERSION = "0.115.4"
{{< /code >}}
For testing:
{{< code file="netlify.toml" >}}
{{< code file=netlify.toml >}}
[context.deploy-preview.environment]
HUGO_VERSION = "0.115.4"
{{< /code >}}
The Netlify configuration file can be a little hard to understand and get right for the different environment, and you may get some inspiration and tips from this site's `netlify.toml`:
{{< readfile file="netlify.toml" highlight="toml" >}}
{{< readfile file=netlify.toml highlight=toml >}}
## Build and deploy site

View File

@@ -2,7 +2,7 @@
title: Host on Render
description: Host your Hugo site for free with Render's global CDN, fully-managed SSL and auto deploys from GitHub.
categories: [hosting and deployment]
keywords: [hosting,deployment]
keywords: [hosting]
menu:
docs:
parent: hosting-and-deployment

View File

@@ -1,8 +1,8 @@
---
title: Hugo Deploy
description: You can upload your site to GCS, S3, or Azure using the Hugo CLI.
description: Upload your site to GCS, S3, or Azure
categories: [hosting and deployment]
keywords: [s3,gcs,azure,hosting,deployment]
keywords: [deployment,s3,gcs,azure]
menu:
docs:
parent: hosting-and-deployment
@@ -13,6 +13,7 @@ toc: true
You can use the "hugo deploy" command to upload your site directly to a Google Cloud Storage (GCS) bucket, an AWS S3 bucket, and/or an Azure Storage container.
## Assumptions
* You have completed the [Quick Start] or have a Hugo website you are ready to deploy and share with the world.
@@ -22,73 +23,202 @@ You can use the "hugo deploy" command to upload your site directly to a Google C
* AWS: [Install the CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) and run [`aws configure`](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html).
* Azure: [Install the CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) and run [`az login`](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli).
* NOTE: Each service supports alternatives for authentication, including using environment variables. See [here](https://gocloud.dev/howto/blob/#services) for more details.
* You have created a bucket to deploy to. If you want your site to be
public, be sure to configure the bucket to be publicly readable as a static website.
* Google Cloud: [create a bucket](https://cloud.google.com/storage/docs/creating-buckets) and [host a static website](https://cloud.google.com/storage/docs/hosting-static-website)
* Amazon S3: [create a bucket](https://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html) and [host a static website](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html)
* Microsoft Azure: [create a storage container](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal) and [host a static website](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website)
## Create a bucket to deploy to
Create a storage bucket to deploy your site to. If you want your site to be
public, be sure to configure the bucket to be publicly readable.
## Configuring your first deployment
### Google Cloud Storage (GCS)
Follow the [GCS instructions for how to create a bucket](https://cloud.google.com/storage/docs/creating-buckets).
### AWS S3
Follow the [AWS instructions for how to create a bucket](https://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html).
### Azure Storage
Follow the [Azure instructions for how to create a storage container](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal).
## Configure the deployment
In the configuration file for your site, add a `[deployment]` section with one
or more `[[deployment.targets]]` section, one for each deployment target. Here's
a detailed example:
In the configuration file for your site, add a `[deployment]` section
and a `[[deployment.targets]]` subsection. The only required parameters are
the name and URL:
```toml
[deployment]
# By default, files are uploaded in an arbitrary order.
# Files that match the regular expressions in the "Order" list
# will be uploaded first, in the listed order.
order = [".jpg$", ".gif$"]
[[deployment.targets]]
# An arbitrary name for this target.
name = "production"
# URL specifies the Go Cloud Development Kit URL to deploy to. Examples:
URL = "<FILL ME IN>"
# Google Cloud Storage -- see https://gocloud.dev/howto/blob/#gcs
#URL = "gs://<Bucket Name>"
# Amazon Web Services S3; see https://gocloud.dev/howto/blob/#s3
# For S3-compatible endpoints, see https://gocloud.dev/howto/blob/#s3-compatible
#URL = "s3://<Bucket Name>?region=<AWS region>"
# Microsoft Azure Blob Storage; see https://gocloud.dev/howto/blob/#azure
#URL = "azblob://$web"
```
## Deploy
To deploy to a target:
```bash
hugo deploy [--target=<target name>]
```
The deploy process recursively walks through your local publish directory
(`public` by default) and syncs it to the destination bucket, to ensure
that the local and remote contents match.
If you don't specify a target, Hugo will deploy to the first target in your
configuration.
See `hugo help deploy` or [the deploy command-line documentation][commandline] for more command-line options.
### How the file list works
The first thing `hugo deploy` does is create file lists for local and remote by
traversing the local publish directory and remote bucket.
For both local and remote, the file list includes and excludes files according to
the [deployment target's configuration][config] --
* If the configuration specifies an `include` pattern, all files
are skipped by default except those matching the pattern.
* If the configuration specifies an `exclude` pattern, files matching the
pattern are skipped.
{{% note %}}
When creating the local file list, a few additional skips apply: first, Hugo always
skips files named `.DS_Store`.
Second, Hugo always skips local hidden directories
(directories with names starting with a period, e.g. `.git`) and does not
traverse into them, except for the special [hidden directory named
`.well-known`](https://en.wikipedia.org/wiki/Well-known_URI), which is
traversed if it exists.
{{% /note %}}
### How the local and remote file lists are compared
In the second step, Hugo compares the two file lists to figure out what changes
actually need to be made on the remote. File names are compared first; if the
local and remote files both exist then the sizes and md5sums are compared. Any
difference means that the file will be (re-)uploaded.
Specifying the `--force` flag will ensure all files are re-uploaded even
if Hugo cannot detect any differences between local and remote.
Files are deleted from the remote bucket if they are not present in the local
file list.
{{% note %}}
If a remote file is excluded from the file list generation using the
exclude/include configs, then the comparison step will not know to delete the
file -- so it will remain on the remote even if it isn't present locally.
{{% /note %}}
If the [`--confirm` or `--dryRun` flags][commandline] are given, Hugo displays
what differences it has found and either pauses or stops here.
### How synchronization works
Hugo applies the list of changes to the remote storage bucket. Missing and/or
changed files are uploaded, and files missing locally but present remotely are
deleted. As files are uploaded, their headers are also configured on the remote
according to the matchers configuration.
{{% note %}}
As a safety measure to help prevent accidents, if there are more than 256 files
to delete, Hugo won't delete any files from the remote. Use the `--maxDeletes`
command line flag to override this.
{{% /note %}}
## Advanced configuration
Here's a full example deployment configuration:
```toml
[deployment]
# By default, files are uploaded in an arbitrary order.
# If you specify an `order` list, files that match regular expressions
# in this list will be uploaded first, in the specified order.
order = [".jpg$", ".gif$"]
[[deployment.targets]]
# Define one or more targets, e.g., staging and production.
# Each target gets its own [[deployment.targets]] section.
# An arbitrary name for this target.
name = "mydeployment"
# The Go Cloud Development Kit URL to deploy to. Examples:
URL = "<FILL ME IN>"
# GCS; see https://gocloud.dev/howto/blob/#gcs
# URL = "gs://<Bucket Name>"
#URL = "gs://<Bucket Name>"
# S3; see https://gocloud.dev/howto/blob/#s3
# For S3-compatible endpoints, see https://gocloud.dev/howto/blob/#s3-compatible
# URL = "s3://<Bucket Name>?region=<AWS region>"
#URL = "s3://<Bucket Name>?region=<AWS region>"
# Azure Blob Storage; see https://gocloud.dev/howto/blob/#azure
# URL = "azblob://$web"
#URL = "azblob://$web"
# You can use a "prefix=" query parameter to target a subfolder of the bucket:
# URL = "gs://<Bucket Name>?prefix=a/subfolder/"
#URL = "gs://<Bucket Name>?prefix=a/subfolder/"
# If you are using a CloudFront CDN, deploy will invalidate the cache as needed.
cloudFrontDistributionID = <ID>
#cloudFrontDistributionID = "<FILL ME IN>"
# Optionally, you can include or exclude specific files.
# See https://godoc.org/github.com/gobwas/glob#Glob for the glob pattern syntax.
# If non-empty, the pattern is matched against the local path.
# All paths are matched against in their filepath.ToSlash form.
# Include or exclude specific files when deploying to this target:
# If exclude is non-empty, and a local or remote file's path matches it, that file is not synced.
# If include is non-empty, and a local or remote file's path does not match it, that file is not synced.
# As a result, local files that don't pass the include/exclude filters are not uploaded to remote,
# Note: local files that don't pass the include/exclude filters are not uploaded to remote,
# and remote files that don't pass the include/exclude filters are not deleted.
# include = "**.html" # would only include files with ".html" suffix
# exclude = "**.{jpg, png}" # would exclude files with ".jpg" or ".png" suffix
#
# The pattern syntax is documented here: https://godoc.org/github.com/gobwas/glob#Glob
# Patterns should be written with forward slashes as separator.
#
#include = "**.html" # would only include files with ".html" suffix
#exclude = "**.{jpg, png}" # would exclude files with ".jpg" or ".png" suffix
# [[deployment.matchers]] configure behavior for files that match the Pattern.
#######################
[[deployment.matchers]]
# Matchers enable special caching, content type and compression behavior for
# specified file types. You can include any number of matcher blocks; the first one
# matching a given file pattern will be used.
# See https://golang.org/pkg/regexp/syntax/ for pattern syntax.
# Pattern searching is stopped on first match.
pattern = "<FILL ME IN>"
# If true, Hugo will gzip the file before uploading it to the bucket.
# With many storage services, this will save on storage and bandwidth costs
# for uncompressed file types.
#gzip = false
# If true, Hugo always re-uploads this file even if size and md5 match.
# This is useful if Hugo isn't reliably able to determine whether to re-upload
# the file on its own.
#force = false
# Content-type header to configure for this file when served.
# By default this can be determined from the file extension.
#contentType = ""
# Cache-control header to configure for this file when served.
# The default is the empty string.
#cacheControl = ""
# Content-encoding header to configure for this file when served.
# By default, if gzip is True, this will be filled with "gzip".
#contentEncoding = ""
# Samples:
@@ -114,21 +244,6 @@ pattern = "^.+\\.(html|xml|json)$"
gzip = true
```
## Deploy
To deploy to a target:
```bash
hugo deploy [--target=<target name>, defaults to first target]
```
Hugo will identify and apply any local changes that need to be reflected to the
remote target. You can use `--dryRun` to see the changes without applying them,
or `--confirm` to be prompted before making changes.
See `hugo help deploy` for more command-line options.
[Quick Start]: /getting-started/quick-start/
[Google Cloud]: [https://cloud.google.com]
[AWS]: [https://aws.amazon.com]
[Azure]: [https://azure.microsoft.com]
[commandline]: /commands/hugo_deploy/
[config]: #advanced-configuration