There are two options to deploy a Gatsby application.
Before running gatsby build
command, we will need to transfer any keys in .env.development
to .env.production
.
We then run this command to get our production already built in public
folder.
gatsby build
We can then run gatsby serve
to see our project.
Netlify is a great option for hosting web applications and static websites.
We can deploy our project to Netlify with two options:
The benefit of deploying a new site from Git is that Netlify will rebuild the site anytime there are changes in the GitHub repo.
When deploying a new site from the Git repository, we need to add Variables from our .env.development
if we have any. We can do that in the “Show Advanced” option.
If we use Headless CMS such as Contentful or Strapi, it will be helpful if we can trigger a rebuild from Contentful any time we change our data.
To do that, we need to follow these steps: