Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy static HTML webpage on AWS Amplify?

Tags:

aws-amplify

I was wondering how I can deploy static HTML website on AWS Amplify. I was able to deploy it but for some reason it is not loading assets, specially images from ./img OR ./images folder. It shows as broken images instead.

I understand that I could host this with S3 and CDN but for this use case I want to use Amplify so that I can automate the deployment with Git.

Any kind of information/help would be great!

like image 384
Aagam Jhaveri Avatar asked Dec 19 '25 13:12

Aagam Jhaveri


1 Answers

I came across this same issue. The issue is that your assets (in your example ./images, but I just have an assets folder, that could have images/css or whatever) might not be reachable from the directory in your AWS Amplify Build settings - at least that was my issue.

Say you have the following Build Settings:

version: 1
frontend:
  phases:
    # IMPORTANT - Please verify your build commands
    build:
      commands: []
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: blog
    files:
      - '**/*'
  cache:
    paths: []

I placed my assets folder in the base directory, which allowed the index.html to read the location of the assets. For example in your index.html code:

<!DOCTYPE html>
<html lang="en">
<head>
   ... relevant meta tags etc here
   <link rel="stylesheet" href="./assets/styles.css">
</head>
<body>
</body>
</html>
like image 197
radleylewis Avatar answered Dec 24 '25 12:12

radleylewis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!