Deploy with hugo
Use the hugo deploy
command to deploy your site Amazon S3, Azure Blob Storage, or Google Cloud Storage.
This feature requires the Hugo extended/deploy edition. See the installation section for details.
Assumptions
You have completed the [Quick Start] or have a Hugo website you are ready to deploy and share with the world.
You have an account with the service provider (AWS, Azure, or Google Cloud) that you want to deploy to.
You have authenticated.
- AWS: Install the CLI and run
aws configure
. - Azure: Install the CLI and run
az login
. - Google Cloud: Install the CLI and run
gcloud auth login
.
Each service supports various authentication methods, including environment variables. See details.
- AWS: Install the CLI and run
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.
AWS: create a bucket and host a static website
Azure: create a storage container and host a static website
Google Cloud: create a bucket and host a static website
Configuration
Create a deployment target in your site configuration. The only required parameters are name
and url
:
deployment:
targets:
- name: production
url: s3://my_bucket?region=us-west-1
[deployment]
[[deployment.targets]]
name = 'production'
url = 's3://my_bucket?region=us-west-1'
{
"deployment": {
"targets": [
{
"name": "production",
"url": "s3://my_bucket?region=us-west-1"
}
]
}
}
Deploy
To deploy to a target:
hugo deploy [--target=<target name>]
This command syncs the contents of your local public
directory (the default publish directory) with the destination bucket. If no target is specified, Hugo deploys to the first configured target.
For more command-line options, see hugo help deploy
or the CLI documentation.
File list creation
hugo deploy
creates local and remote file lists by traversing the local publish directory and the remote bucket. Inclusion and exclusion are determined by the deployment target’s configuration:
include
: All files are skipped by default except those that match the pattern.exclude
: Files matching the pattern are skipped.
During local file list creation, Hugo skips .DS_Store
files and hidden directories (those starting with a period, like .git
), except for the .well-known
directory, which is traversed if present.
File list comparison
Hugo compares the local and remote file lists to identify necessary changes. It first compares file names. If both exist, it compares sizes and MD5 checksums. Any difference triggers a re-upload, and remote files not present locally are deleted.
Excluded remote files (due to include
/exclude
configuration) won’t be deleted.
The --force
flag forces all files to be re-uploaded, even if Hugo detects no local/remote differences.
The --confirm
or --dryRun
flags cause Hugo to display the detected differences and then pause or stop.
Synchronization
Hugo applies the changes to the remote bucket: uploading missing or changed files and deleting remote files not present locally. Uploaded file headers are configured remotely based on the matchers configuration.
To prevent accidental data loss, Hugo will not delete more than 256 remote files by default. Use the --maxDeletes
flag to override this limit.
Advanced configuration
See configure deployment.