# Deploying Gatsby to Netlify

> Source: https://agilitycms.com/docs/gatsby/deploying-gatsby-to-netlify

This guide will cover how you can deploy our [Gatsby Blog Starter](https://github.com/agility/agilitycms-gatsby-starter) using our Automated Netlify Deployment.

## Deploying to Netlify

> You will need to have a GitHub and a Netlify account to get your project deployed.

To start, head by going into **Settings > Sitemaps**, then click **Setup Deployment**.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-03-11-at-12.57.25-PM-09302021151601.png)

Select the Netlify Automated Deployment.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-07-19-at-11.47.15-AM-09302021151614.png)

Allow Netlify to connect with your Github account.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-07-29-at-11.49.54-AM-09302021151928.png)

Next, Netlify will create a repository in your GitHub account with the name you choose. When you're ready, click on **Save & Deploy**.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-07-29-at-11.50.38-AM-09302021151956.png)

Once complete, Netlify will deploy a copy of the Agility CMS & Gatsby Starter Template on a unique domain.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-07-29-at-12.14.50-PM-09302021152935.png)

## Setting Up a Production Domain in Agility

To set up your Production Domain in Agility, copy the Deployment URL Netlify generated for you upon deploying your site. Set up a deployment in Agility by going to **Settings > Sitemaps** and click on the **Setup Deployment** button. From there, select a **Custom Deployment**.

Enter your deployment details and click **Save**.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-07-29-at-12.16.18-PM-09302021154704.png)

Your Production Domain will then be configured.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-07-29-at-12.16.52-PM-09302021154722.png)

## Setting Up Preview

When setting up a Preview Environment for Gatsby, we recommend using the [Gatsby Cloud](https://www.gatsbyjs.com/products/cloud/) platform, specifically created for the Gatsby framework.

[Configure Gatsby Cloud Previews](https://agilitycms-documentation-site.vercel.app/docs/gatsby/configure-gatsby-cloud-previews)

## Rebuilding Your Site with Webhooks

You can rebuild your Gatsby site deployed on Netlify with Webhooks. In Netlify, go to **Site Settings > Build & Deploy > Build Hooks** to create a new webhook. Give your webhook a name a select a branch you would like to rebuild. Click Save and copy the URL Netlify generates for you.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-07-19-at-5.41.46-PM-09302021160839.png)

In Agility, go to **Settings > Web Hooks** to add a new webhook. Give your Webhook a name and paste in the URL.

For **Production builds**, make sure *Receive Content Publish Events* is checked off.

For **Preview builds**, uncheck *Receive Content Publish Events*, and check off *Receive Content Save Events*.

You can test the Webhook by sending a test payload.

![](https://cdn.aglty.io/agility-cms-docs/block-editor/gatsbyarticles/Screen-Shot-2021-05-27-at-12.05.13-PM-09302021160938.png)
