How to host a Shopify export on Amazon S3

Short answer

To host a Shopify storefront export on Amazon S3, create a bucket with static website hosting, make it public, and run aws s3 sync ./exported-site s3://my-bucket --delete. Add CloudFront for HTTPS. The copy has no checkout, so redirect /cart and /checkout to your Shopify store with routing rules.

Last reviewed

Key facts

  • Routing rules can redirect to a different host with the HostName and Protocol fields.
  • S3 serves GET and HEAD only on the website endpoint.
  • Static files hold no cart, no checkout and no live inventory.
  • Shopify’s product CSV leaves out images and collection membership.

What a Shopify export brings to Amazon S3

WebExport saves Shopify storefront pages, product layouts, collection pages, fonts and images as static files. S3 stores and serves them. The result is a catalog site with no order path of its own, and the easiest way to give it one is to hand visitors back to Shopify when they want to buy.

S3 can do that without any code. A routing rule matches a key prefix and sends the visitor to another host with a chosen status. Three short rules cover the cart, checkout and account paths.

Create the bucket and sync the folder

  1. Create a bucket and turn on static website hosting with index.html as the index document and 404.html as the error document.
  2. Turn off Block Public Access for that bucket and attach a bucket policy that allows s3:GetObject for everyone.
  3. Upload the folder with the AWS CLI, using --delete so removed pages disappear from the bucket.
  4. Put CloudFront in front of the website endpoint for HTTPS and your own domain.
terminal
aws s3 sync ./exported-site s3://my-bucket --delete

Redirects, headers and 404s on Amazon S3

The S3 website endpoint is HTTP only and has no header configuration, so security headers and HTTPS come from CloudFront. An S3 error document covers 4XX responses, and routing rules are limited to 50 per website configuration. For single pages you can set the x-amz-website-redirect-location metadata on an object, and the website endpoint answers it with a 301. Index documents work at every folder level on the website endpoint, but not through the REST endpoint.

Add these rules to the RoutingRules list of your website configuration. They send three server-only paths to the Shopify store.

website.json (RoutingRules)
"RoutingRules": [
  {
    "Condition": { "KeyPrefixEquals": "cart" },
    "Redirect": { "HostName": "your-store.myshopify.com", "Protocol": "https",
                  "ReplaceKeyPrefixWith": "cart", "HttpRedirectCode": "302" }
  },
  {
    "Condition": { "KeyPrefixEquals": "checkout" },
    "Redirect": { "HostName": "your-store.myshopify.com", "Protocol": "https",
                  "ReplaceKeyPrefixWith": "checkout", "HttpRedirectCode": "302" }
  },
  {
    "Condition": { "KeyPrefixEquals": "account" },
    "Redirect": { "HostName": "your-store.myshopify.com", "Protocol": "https",
                  "ReplaceKeyPrefixWith": "account", "HttpRedirectCode": "302" }
  }
]

Prefix matching is literal, so the cart rule also catches any top-level key starting with cart, such as cart-guide. Name your own pages with that in mind, or use per-object redirects for exact matches. Apply the whole configuration with aws s3api put-bucket-website. Replace your-store with your own myshopify.com handle.

Shopify output that needs fixing on Amazon S3

Shopify export: what to check
In the Shopify outputWhat to do on any static host
/cart and /checkout pathsThese are server pages. The static copy has no cart, so link buyers to your Shopify checkout or a buy button.
Calls to /cart.js and product .js endpointsThese live Shopify endpoints return 404 on a static host. Remove or replace the scripts that call them.
Prices and stock frozen at export timeProduct pages show the values from the day of the export. Re-export after price changes.
Images from cdn.shopify.comRewritten to local paths. Check large collection pages, because product images add up quickly.

Find theme scripts that call /cart.js, /cart/add.js or product .js endpoints. They exist only on Shopify, so they fail on a bucket. Replace add to cart with a link to the product on your store. Theme contact forms post to Shopify too, so swap them for a hosted endpoint. Re-export after price changes, because the pages are frozen at the export date.

Forms and dynamic features

S3 serves files and nothing else. Use a form service, or send the form to an API Gateway endpoint backed by a function you write.

Use a hosted form service for contact and newsletter forms. The bucket answers only GET and HEAD on its website endpoint, so a POST to it is rejected.

What can go wrong

  • A page whose key starts with cart, checkout or account is redirected by the prefix rules.
  • Product pages that show a sale price after the sale ends mislead buyers. Re-export on a schedule you keep.
  • Image heavy catalogs raise transfer costs, so convert images to WebP before you upload.

Frequently asked questions

Can I sell from a Shopify copy on S3?

Not by itself. Redirect the buy path to your Shopify store or another checkout, and use S3 for the browsing pages.

How do I redirect to another domain with S3 routing rules?

Use the Redirect object with HostName and Protocol, plus ReplaceKeyPrefixWith and HttpRedirectCode, as the S3 redirect docs show.

Are product images included in the export?

Yes. Images used on the storefront pages are saved and their links rewritten from cdn.shopify.com to local paths.

Do I need CloudFront in front of the bucket?

For HTTPS and your own domain, yes. The website endpoint does not support HTTPS, per the S3 docs.

Official documentation

Free tools for this job

Get the Shopify files first

Paste your public Shopify URL into the export form and download a ZIP you can deploy to Amazon S3. The Free plan covers 1 site, 5 exports a month, 15 pages and 20 MB per export. Professional is a $9.99 one-time purchase with unlimited pages.