Deploy Your Site to Netlify

This guide walks you through deploying a static site (or a Jamstack app) to Netlify using both the CLI and Git integration. Follow each step, copy the commands with a click, and get your site live in minutes.

1️⃣ Prerequisites

2️⃣ Install the Netlify CLI

npm install -g netlify-cli

Verify the installation:

netlify --version

3️⃣ Authenticate

netlify login

This opens a browser window where you authorize the CLI.

4️⃣ Deploy Your Site

From your project root:

netlify init

When prompted, select “Create & configure a new site”. After the setup, run a one‑time deploy:

netlify deploy --prod

Your site will be live at your‑site‑name.netlify.app. You can customize the subdomain in the Netlify UI.

5️⃣ Enable Continuous Deployment (Git)

  1. Push your repo to GitHub (or GitLab/Bitbucket).
  2. In Netlify UI, click New site from Git and connect your repo.
  3. Set the build command (e.g., npm run build) and the publish directory (e.g., dist).

Every push to the main branch triggers a fresh deploy automatically.

6️⃣ Add Environment Variables

In your site dashboard → Site settings** → **Build & deploy → Environment**. Click New variable and add keys like API_KEY.

netlify env:set API_KEY your_key_here

📚 Frequently Asked Questions

How do I rollback a deployment?

In the Netlify UI, go to Deploys**, click the three‑dot menu on a previous deploy, and select **Rollback**.

Can I host a serverless function?

Yes! Place functions in a folder named netlify/functions. They become accessible at /api/your‑function.

How do I set a custom domain?

In Domain management**, add your domain and follow the DNS instructions provided by Netlify.