Introduction
This tutorial will guide you on how to deploy Clay, a Gatsby project, to Netlify. This walkthrough assumes you have a basic understanding of Git, Node.js, npm, and have a Clay project ready to be deployed.
Prerequisites
- A working Clay application.
- Git installed on your machine.
- A Netlify account.
- Netlify CLI installed on your machine.
Step 1: Prepare Your Clay Application
Before deploying your application, you need to ensure that your Clay application is ready for production. Follow the previous guide to create and configure your Clay application for production. Once done, your application should have a successful production build with the command:
npm run clean npm run build
This process ensures all development files are cleaned before creating the production build.
Step 2: Install Netlify CLI
Netlify CLI is a powerful tool that allows you to control and configure Netlify right from your terminal. If you haven't installed it yet, you can do so with npm:
npm install netlify-cli -g
Step 3: Login to Your Netlify Account
After installing the Netlify CLI, you need to log in to your Netlify account. You can do this by running the following command in your terminal:
netlify login
This command will open your web browser for you to log in to your account. If the browser does not open, you can manually copy the URL from the terminal and paste it into your browser.
Step 4: Initialize Your Clay Project with Netlify
Navigate to your Clay project directory, and initialize it with Netlify by running the following command:
netlify init
This command will prompt you to provide some details about your project:
- You can choose to link the project to an existing Netlify site or create a new one.
- Provide a command to build your project. For a Clay project, this is usually
npm run build
. - Specify the directory that Netlify should deploy. For a Clay project, this is the
public
directory.
After providing these details, Netlify will create a new site linked to your Git repository.
Step 5: Deploy Your Clay Project
Now that everything is set up, you can deploy your project to Netlify by running:
netlify deploy --prod
This command will deploy your site to Netlify, and if everything goes well, you should see a URL in the terminal where your site is live.
Congratulations! You have successfully deployed your Clay application to Netlify.