Skip to main content

Deploy Hugo static websites to AWS

Project description

CDK-Hugo-Deploy

This is an AWS CDK Construct for easily deploying Hugo Static websites to AWS S3 behind SSL/Cloudfront.

Usage

Before deploying, run the hugo command in your Hugo project to generate a built site in the public directory.

Typescript

import { App, Stack, StackProps } from 'aws-cdk-lib';
import { HugoDeploy } from 'cdk-hugo-deploy';

export class MyStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    new HugoDeploy(this, 'HugoDeploy', {
      publicDir: 'path/to/hugo-project/public',
      domainName: 'example.com'  // Domain you already have a hosted zone for
    });
}

Python

from constructs import Construct
from aws_cdk import Stack
from cdk_hugo_deploy import HugoDeploy

class MyStack(Stack):
    def __init__(self, scope: Construct, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        HugoDeploy(self, "HugoDeploy",
            public_dir="path/to/hugo-project/public",
            domain_name="example.com"
        )

Prerequisites

Assumes that there is already a Route53 hosted zone for domainName that can be looked up

Why this construct?

Other constructs for deploying Single Page Applicationis (SPA) such as CDK-SPA-Deploy don't account for how Hugo handles paths that end in /.

This construct includes a Cloudfront Function to rewrite paths to ensure /path/to/page/ will request /path/to/page/index.html from the S3 Origin.

Contributing

Please open an issue with any updates/features you'd like on this

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk-hugo-deploy-0.0.347.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdk_hugo_deploy-0.0.347-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file cdk-hugo-deploy-0.0.347.tar.gz.

File metadata

  • Download URL: cdk-hugo-deploy-0.0.347.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for cdk-hugo-deploy-0.0.347.tar.gz
Algorithm Hash digest
SHA256 13f45bf6c81da4d7f85f98e57ec37c9f9760cfd769b7671e79706f8426eba7a4
MD5 a2201818750252458e7f04f65fc5d76e
BLAKE2b-256 cab280ce66019bf1b29a4c608f9d9f294ae793ab98e45dae4691c0bb7de68407

See more details on using hashes here.

File details

Details for the file cdk_hugo_deploy-0.0.347-py3-none-any.whl.

File metadata

File hashes

Hashes for cdk_hugo_deploy-0.0.347-py3-none-any.whl
Algorithm Hash digest
SHA256 3bdf9d9668b8e872bfde900fd5ca8baa7f2d82ff333bcbe7d789eb37b2e7e734
MD5 03ec8dbced537034be15ee6498c37123
BLAKE2b-256 5dd3a0e650cd31a6e7bb4eedbdeb6b20217f12318b4834928ab4eef277efd097

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page