An excellent solution to deploy a Gatsby website to production is to use Netlify. Netlify is a web hosting platform that offers cloud hosting and serverless backends for static websites.
This tutorial will guide you on how to deploy a Gatsby website to Netlify from a Git Repository.
Before you start
Learn how to Set Up your Gatsby Development Environment
Head to the Netlify website and create or log in to your account.
Once you're logged in you can add a new site by importing from a Git repository.
Connect to your Git provider.
Search for and select the Git repository of the website you wish to host.
Once you've selected your Git repository, fill out your build settings. Be sure to click "Advanced Settings" to include the environment variables needed for your Gatsby production build.
You can find the Keys needed for your environment variable under Settings > API Keys:
AGILITY_API_ISPREVIEW = false AGILITY_API_KEY = LIVE API KEY
AGILITY_GUID = INSTANCE GUID
When you're done, click deploy!
When your deployment is done, Netlify will provide you with a temporary deployment URL. A custom domain can be added to your site by navigating into the Domain settings.