HUGO
News Docs Themes Community GitHub

Deploy with hugo

Deploy your site with the hugo CLI.

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

  1. You have completed the [Quick Start] or have a Hugo website you are ready to deploy and share with the world.

  2. You have an account with the service provider (AWS, Azure, or Google Cloud) that you want to deploy to.

  3. You have authenticated.

    Each service supports various authentication methods, including environment variables. See details.

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

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.