Deploy an Astro Blog to AWS Amplify
Published: 2023-03-28 15:53:45

Astro.js is a modern web development framework that allows developers to build static websites and web applications using components, with support for server-side rendering, data fetching, and other advanced features. 

AWS Amplify Hosting, is a subset of AWS Amplify tools and features that enable developers to deploy and manage their web applications with ease.

In this tutorial, we will cover the steps required to deploy an Astro.js website to AWS Amplify Hosting.


## **Create an Astro Project**

Run the following command to create an Astro project on your computer:

```sh
npm create astro@latest
```

Give the project a name.

Choose the blog template so we can test with a production ready blog website. Go with the default settings for the rest of the [wizard prompts](https://docs.astro.build/en/tutorial/1-setup/2/#launch-the-astro-setup-wizard).

Run the following to ensure that your set up works:

```sh
npm run dev
```

## **Setup Walkthrough**

The website has a static home page, about page and blog index page that aggregates all your blog posts. It also has a statically generated blog pages for each blog entry.

The home and about pages are direct children of the `pages` folder while the blog page is an `index.astro` file inside `pages/blog` folder. The statically generated pages are setup with the slug file in `pages/blog` folder.


## **Deploy to AWS Amplify**

You need to have a git repository deployed to a git provider such as Github. With a git repository, Amplify Hosting can set up continuous delivery automatically. Commit all your changes to Git and push your website to Github.

Go to your AWS console and search AWS Amplify. Open it, click the New App dropdown and choose Host web app:

![](https://paper-attachments.dropboxusercontent.com/s_208BBC71EE9C650048130A4DF0250E0533D46D07F1107ED193AB957EE1B9CD8F_1678731929547_file.png)


Choose your Git provider and click Connect branch

![](https://paper-attachments.dropboxusercontent.com/s_208BBC71EE9C650048130A4DF0250E0533D46D07F1107ED193AB957EE1B9CD8F_1678731929551_file.png)


Choose the repository, select a branch and click Next


![](https://paper-attachments.dropboxusercontent.com/s_208BBC71EE9C650048130A4DF0250E0533D46D07F1107ED193AB957EE1B9CD8F_1678731929556_file.png)


In the build settings page, choose Create new environment and choose a role or create a new role that allows Amplify Hosting to access your resources.


![](https://paper-attachments.dropboxusercontent.com/s_208BBC71EE9C650048130A4DF0250E0533D46D07F1107ED193AB957EE1B9CD8F_1678731929562_file.png)


Click Edit to edit the build settings. Change the `baseDirectory` to `dist` and click save.

![](https://paper-attachments.dropboxusercontent.com/s_208BBC71EE9C650048130A4DF0250E0533D46D07F1107ED193AB957EE1B9CD8F_1678731929567_file.png)


Click Next and Click Save and Deploy. Give the deployment process a minute or two and once it is done, click the production URL to preview the website.


![](https://paper-attachments.dropboxusercontent.com/s_208BBC71EE9C650048130A4DF0250E0533D46D07F1107ED193AB957EE1B9CD8F_1678733294392_CleanShot+2023-03-13+at+6.47.312x.png)



## Conclusion

Congratulations! You have successfully deployed your Astro.js website to AWS Amplify Hosting. By leveraging the power of AWS Amplify, you can easily host and scale your website with minimal effort, allowing you to focus on building great web experiences for your users.


## Resources


- [CLI deploy](https://docs.amplify.aws/cli/hosting/hosting/)
- [Set up a custom domain](https://docs.aws.amazon.com/amplify/latest/userguide/custom-domains.html)
- [Configure build settings](https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html)