Hugo to AWS S3 Deploy Command

Here’s a quick snippet of code to put your shell aliases file that cds into your Hugo directory, builds the site, deploys it to AWS S3, and then invalidates the cache.

function hugo-deploy () {
    cd /path/to/hugo/site
    hugo
    aws s3 sync /path/to/hugo/site s3://your_site_s3_bucket/
    aws cloudfront create-invalidation --distribution-id AAAAWWWWWSSSS1111 --paths "/*"
}

2020

Random Related Links