Hedgerules (Hugo Edge Rules) makes hugo deploy work seamlessly with CloudFront and S3.
It was created to provide directory redirects, index rewrites, and custom headers for AWS-hosted Hugo sites, to enable migration from Netlify which implements those features natively.
When using CloudFront with S3 REST (private bucket, HTTPS to S3), you have to implement directory index redirects, index file rewriting, custom headers, and redirects yourself. Hedgerules implements these features using CloudFront Functions and CloudFront Key Value Store (KVS).
See https://hedgerules.micahrl.com for complete documentation and examples. That site is deployed with Hedgerules!
Deployment workflow:
- Create S3 bucket, CloudFront Distribution, and KVS resources out of band (e.g. CloudFormation).
- Run
hugoto build the site, generating_hedge_redirects.txtand_hedge_headers.json. - Run
hedgerules deployto create/update CloudFront Functions and sync KVS entries. - Run
hugo deployto publish the site to S3 and invalidate the CloudFront cache.
See the deployment docs for the full 5-stage setup.
Contributions welcome. I'm especially interested in:
- Supporting more clouds
- Some form of HTTP basic authentication
- Other features that would be useful and free (or basically free) for personal-scale websites