Export Static HTML to S3 and a CDN

Export a complete landing page, upload it to object storage, serve it through a CDN, and automate repeatable updates.

What this publishing pattern does

StaticPagesApi remains the editable source for the page. The exported HTML file becomes the production artifact stored in S3 or another object store.

A CDN such as CloudFront can serve that artifact from your public domain without sending ordinary page requests back to the StaticPagesApi application.

Export the approved page

Open the active page in StaticPagesApi and use its Export action after reviewing metadata, links, images, responsive behavior, and any embedded scripts. Save the resulting document as index.html in a dedicated local release directory.

  • Treat the export as a deployable build artifact rather than the editable source.
  • Keep uploaded image URLs reachable from the public destination.
  • Re-export whenever page records, templates, fragments, or head scripts change.

Upload the HTML document to S3

Use a bucket and key that match the route your CDN or static host should serve. The example publishes a campaign at /spring-campaign/.

aws s3 cp ./release/index.html   s3://YOUR_PUBLIC_PAGE_BUCKET/spring-campaign/index.html   --content-type "text/html; charset=utf-8"   --cache-control "public, max-age=300"

Put a CDN and your domain in front of the bucket

Configure the CDN origin, TLS certificate, public hostname, default document behavior, and route mapping outside StaticPagesApi. Keep direct bucket access private when your CDN supports origin access controls.

  • Make /spring-campaign/ resolve to spring-campaign/index.html.
  • Redirect alternate hostnames and URL variants to one canonical public URL.
  • Use a short HTML cache lifetime or invalidate the changed path after publishing.

Invalidate the changed page after an update

If the CDN cached the previous document, invalidate only the updated route instead of clearing every cached asset.

aws cloudfront create-invalidation   --distribution-id YOUR_DISTRIBUTION_ID   --paths "/spring-campaign" "/spring-campaign/" "/spring-campaign/index.html"

Automate later publishes with a signed webhook

For repeatable publishing, configure a receiver that verifies the StaticPagesApi signature, writes the exact request body to the expected S3 key, and invalidates only the affected CDN path after a successful upload.

Verify the production result

Open the final public URL and confirm the status, canonical tag, title, description, images, scripts, calls to action, responsive layout, and analytics events. The public URL—not the editor preview—is the version search engines and customers evaluate.