Hugo Deploy - no gzipping or contentType

Hey all. For some reason Hugo “deploy” to aws doesn’t seem to be working correctly. I’m guessing I have the syntax wrong but not sure. When I look at the files in s3 it appears files aren’t being gzipped and the cacheControl headers aren’t being set.

I’m including my settings below.

deployment:
  targets:
    - name: production
      URL: "s3://rest-here"
      cloudFrontDistributionID: ID-here
    matchers:
    - pattern: "^.+\\.(html)$"
      cacheControl: "max-age=2592000, private"
      contentType: "text/html; charset=utf-8"
      gzip: true
    matchers:
    - pattern: "^.+\\.(css)$"
      cacheControl: "max-age=1209600, public"
      contentType: "text/css; charset=utf-8"
      gzip: true
    matchers:
    - pattern: "^main\\.(js)$"
      cacheControl: "max-age=604800, private"
      contentType: "text/javascript; charset=utf-8"
      gzip: true
    matchers:
    - pattern: "^.+\\.(xml)$"
      contentType: "application/xml; charset=utf-8"
      gzip: true
    matchers:
    - pattern: "^json\\.webmanifest$"
      cacheControl: "max-age=604800, public"
      contentType: "application/manifest+json; charset=utf-8"
      gzip: true
    matchers:
    - pattern: "^.+\\.(webp|avif)$"
      cacheControl: "max-age=2592000, no-transform, public"
      gzip: false
    matchers:
    - pattern: "^.+\\.(woff2)$"
      cacheControl: "max-age=2592000, no-transform, public"
      contentType: "font/woff2"
      gzip: false

Can you run hugo config and see if the decoded config matches your expectations.

Strangely it’s only catching the woff files.

[deployment]
invalidatecdn = true
maxdeletes = 256
workers = 10

[[deployment.matchers]]
cachecontrol = 'max-age=2592000, no-transform, public'
contenttype = 'font/woff2'
pattern = '^.+\.(woff2)$'

[[deployment.targets]]
cloudfrontdistributionid = 'id here'
name = 'production'
url = 's3://region stuff'

If you run hugo config --format yaml you get the YAML version …

I’m pretty bad in YAML, but someone will surely spot the error …

I figured it out. I suspected there should only be one “matchers” with a bunch of “pattern” sections underneath it. I removed the multiple matchers in my yaml so there is only one and redeployed, and everything looks to be encoded and with the proper metadata now.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.