Adding a Custom Domain to Your Site on Gatsby Cloud
Gatsby Cloud allows you to specify Custom Domains for your Gatsby websites. This guide provides the steps for applying Custom Domains to your sites on Gatsby Cloud.
Before you can add a custom domain, you’ll need to be hosting with Gatsby Cloud. If you haven’t already, turn on Gatsby Hosting.
- Go to Site Settings > Hosting.
- Click “Add Domain” above the domain list to start the process
- In the “Please enter a domain” field, add one of the following:
- your apex or root domain (this is your custom domain without the www. part, e.g. mysite.com)
- your subdomain (e.g., www.mysite.com or store.mysite.com)
Whichever one you choose will become the primary domain for your site.
If you add an apex domain, Gatsby Hosting will automatically add a redirect that points the www. subdomain to the apex domain. Similarly, if you add a www. subdomain, Gatsby Hosting will automatically add a redirect that points the apex domain to it. Read more about redirected domains in Working with Redirected Domains.
Next you’ll need to visit your 3rd party DNS registrar (e.g. GoDaddy, NameCheap, etc.) to add some DNS records. A DNS Record is an entry in a DNS with details about how to route a request for a given domain name.
If you added an apex domain, you will need to add an Address Mapping Record (A Record).
- Copy one of the IP addresses from the “Value” column for the A records shown next to your custom domain.
- In your DNS provider’s domain settings, create an A Record for the IP address you chose.
The A Record must point to one of the IP addresses shown for your site. It is only necessary to create an A Record for one of the IP addresses listed.
Here’s documentation on adding DNS records for some popular name registrars:
- Go Daddy: A Record | CNAME
- Name.com: A Record | CNAME
- NameCheap: A Record | CNAME
- Google Domains: A Record | CNAME
Note: DNS records need to be fully propagated in order to properly verify the certificates. If not, SSL certification generation will fail.
If you encounter errors related to the the connection not being secure, please allow a few minutes as it can take time for DNS changes to take effect and be detected by all browsers. Use this time to verify that you followed the above steps completely.