| 1 |
--- |
| 2 |
title: Configure deployment |
| 3 |
linkTitle: Deployment |
| 4 |
description: Configure deployments to Amazon S3, Azure Blob Storage, or Google Cloud Storage. |
| 5 |
categories: [] |
| 6 |
keywords: [] |
| 7 |
--- |
| 8 |
|
| 9 |
> [!NOTE] |
| 10 |
> This configuration is only relevant when running `hugo deploy`. See [details][hugo deploy]. |
| 11 |
|
| 12 |
## Top-level settings |
| 13 |
|
| 14 |
These settings control the overall behavior of the deployment process. This is the default configuration: |
| 15 |
|
| 16 |
{{< code-toggle file=hugo config=deployment />}} |
| 17 |
|
| 18 |
`confirm` |
| 19 |
: (`bool`) Whether to prompt for confirmation before deploying. Default is `false`. |
| 20 |
|
| 21 |
`dryRun` |
| 22 |
: (`bool`) Whether to simulate the deployment without any remote changes. Default is `false`. |
| 23 |
|
| 24 |
`force` |
| 25 |
: (`bool`) Whether to re-upload all files. Default is `false`. |
| 26 |
|
| 27 |
`invalidateCDN` |
| 28 |
: (`bool`) Whether to invalidate the CDN cache listed in the deployment target. Default is `true`. |
| 29 |
|
| 30 |
`maxDeletes` |
| 31 |
: (`int`) The maximum number of files to delete, or `-1` to disable. Default is `256`. |
| 32 |
|
| 33 |
`matchers` |
| 34 |
: (`[]*Matcher`) A slice of [matchers](#matchers-1). |
| 35 |
|
| 36 |
`order` |
| 37 |
: (`[]string`) An ordered slice of [regular expressions](g) that determines upload priority (left to right). Files not matching any expression are uploaded last in an arbitrary order. |
| 38 |
|
| 39 |
`target` |
| 40 |
: (`string`) The target deployment [`name`](#name). Defaults to the first target. |
| 41 |
|
| 42 |
`targets` |
| 43 |
: (`[]*Target`) A slice of [targets](#targets-1). |
| 44 |
|
| 45 |
`workers` |
| 46 |
: (`int`) The number of concurrent workers to use when uploading files. Default is `10`. |
| 47 |
|
| 48 |
## Targets |
| 49 |
|
| 50 |
A target represents a deployment target such as "staging" or "production". |
| 51 |
|
| 52 |
`cloudFrontDistributionID` |
| 53 |
: (`string`) The CloudFront Distribution ID, applicable if you are using the Amazon Web Services CloudFront CDN. Hugo will invalidate the CDN when deploying this target. |
| 54 |
|
| 55 |
`exclude` |
| 56 |
: (`string`) A [glob pattern](g) matching files to exclude when deploying to this target. Local files failing the include/exclude filters are not uploaded, and remote files failing these filters are not deleted. |
| 57 |
|
| 58 |
`googleCloudCDNOrigin` |
| 59 |
: (`string`) The Google Cloud project and CDN origin to invalidate when deploying this target, specified as `<project>/<origin>`. |
| 60 |
|
| 61 |
`include` |
| 62 |
: (`string`) A [glob pattern](g) matching files to include when deploying to this target. Local files failing the include/exclude filters are not uploaded, and remote files failing these filters are not deleted. |
| 63 |
|
| 64 |
`name` |
| 65 |
: (`string`) An arbitrary name for this target. |
| 66 |
|
| 67 |
`stripIndexHTML` |
| 68 |
: (`bool`) Whether to map files named `<dir>/index.html` to `<dir>` on the remote (except for the root `index.html`). This is useful for key-value cloud storage (e.g., Amazon S3, Google Cloud Storage, Azure Blob Storage) to align canonical URLs with object keys. Default is `false`. |
| 69 |
|
| 70 |
`url` |
| 71 |
: (`string`) The [destination URL](#destination-urls) for deployment. |
| 72 |
|
| 73 |
## Matchers |
| 74 |
|
| 75 |
A Matcher represents a configuration to be applied to files whose paths match |
| 76 |
the specified pattern. |
| 77 |
|
| 78 |
`cacheControl` |
| 79 |
: (`string`) The caching attributes to use when serving the blob. See [details][cacheControl]. |
| 80 |
|
| 81 |
`contentEncoding` |
| 82 |
: (`string`) The encoding used for the blob's content, if any. See [details][contentEncoding]. |
| 83 |
|
| 84 |
`contentType` |
| 85 |
: (`string`) The media type of the blob being written. See [details][contentType]. |
| 86 |
|
| 87 |
`force` |
| 88 |
: (`bool`) Whether matching files should be re-uploaded. Useful when other route-determined metadata (e.g., `contentType`) has changed. Default is `false`. |
| 89 |
|
| 90 |
`gzip` |
| 91 |
: (`bool`) Whether the file should be gzipped before upload. If so, the `ContentEncoding` field will automatically be set to `gzip`. Default is `false`. |
| 92 |
|
| 93 |
`pattern` |
| 94 |
: (`string`) A [regular expression](g) used to match paths. Paths are converted to use forward slashes (`/`) before matching. |
| 95 |
|
| 96 |
## Destination URLs |
| 97 |
|
| 98 |
Service|URL example |
| 99 |
:--|:-- |
| 100 |
Amazon Simple Storage Service (S3)|`s3://my-bucket?region=us-west-1` |
| 101 |
Azure Blob Storage|`azblob://my-container` |
| 102 |
Google Cloud Storage (GCS)|`gs://my-bucket` |
| 103 |
|
| 104 |
With Google Cloud Storage you can target a subdirectory: |
| 105 |
|
| 106 |
```text |
| 107 |
gs://my-bucket?prefix=a/subdirectory |
| 108 |
``` |
| 109 |
|
| 110 |
You can also to deploy to storage servers compatible with Amazon S3 such as: |
| 111 |
|
| 112 |
- [Ceph][] |
| 113 |
- [MinIO][] |
| 114 |
- [SeaweedFS][] |
| 115 |
|
| 116 |
For example, the `url` for a MinIO deployment target might resemble this: |
| 117 |
|
| 118 |
```text |
| 119 |
s3://my-bucket?endpoint=https://my.minio.instance&awssdk=v2&use_path_style=true&disable_https=false |
| 120 |
``` |
| 121 |
|
| 122 |
## Example |
| 123 |
|
| 124 |
{{< code-toggle file=hugo >}} |
| 125 |
[deployment] |
| 126 |
order = ['.jpg$', '.gif$'] |
| 127 |
[[deployment.matchers]] |
| 128 |
cacheControl = 'max-age=31536000, no-transform, public' |
| 129 |
gzip = true |
| 130 |
pattern = '^.+\.(js|css|svg|ttf)$' |
| 131 |
[[deployment.matchers]] |
| 132 |
cacheControl = 'max-age=31536000, no-transform, public' |
| 133 |
gzip = false |
| 134 |
pattern = '^.+\.(png|jpg)$' |
| 135 |
[[deployment.matchers]] |
| 136 |
contentType = 'application/xml' |
| 137 |
gzip = true |
| 138 |
pattern = '^sitemap\.xml$' |
| 139 |
[[deployment.matchers]] |
| 140 |
gzip = true |
| 141 |
pattern = '^.+\.(html|xml|json)$' |
| 142 |
[[deployment.targets]] |
| 143 |
url = 's3://my_production_bucket?region=us-west-1' |
| 144 |
cloudFrontDistributionID = 'E1234567890ABCDEF0' |
| 145 |
exclude = '**.{heic,psd}' |
| 146 |
name = 'production' |
| 147 |
[[deployment.targets]] |
| 148 |
url = 's3://my_staging_bucket?region=us-west-1' |
| 149 |
exclude = '**.{heic,psd}' |
| 150 |
name = 'staging' |
| 151 |
{{< /code-toggle >}} |
| 152 |
|
| 153 |
[Ceph]: https://ceph.com/ |
| 154 |
[MinIO]: https://www.minio.io/ |
| 155 |
[SeaweedFS]: https://github.com/chrislusf/seaweedfs |
| 156 |
[cacheControl]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control |
| 157 |
[contentEncoding]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding |
| 158 |
[contentType]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type |
| 159 |
[hugo deploy]: /host-and-deploy/deploy-with-hugo-deploy/ |