Quick Answer

Yes! Use the --dir flag to deploy a pre-built static directory:

Terminal window
netlify deploy --dir=./dist
netlify deploy --dir=./dist --prod # Deploy directly to production

Overview

Netlify CLI supports deploying static directories without triggering a build. This is useful when:

  • You’ve already built your site locally
  • Your CI/CD has produced build artifacts
  • You want to deploy pre-generated static files

Installation

Terminal window
npm install -g netlify-cli

Requirements: Node.js version 20.12.2 or above

Deploy Commands

Draft Deploy (Default)

Deploy to a unique preview URL for testing:

Terminal window
netlify deploy --dir=./build
netlify deploy --dir=./dist
netlify deploy --dir=./output

This creates a draft deployment with a random alphanumeric subdomain for previewing and testing before going live.

Production Deploy

Skip the draft and deploy directly to your live site:

Terminal window
netlify deploy --dir=./dist --prod

The --prod flag deploys directly to your site’s main URL.

Skip Build Step

If your files are already built, skip the build command:

Terminal window
netlify deploy --dir=./dist --prod --no-build

Use --no-build when:

  • Your project has already been built
  • You have no build command configured
  • You’re deploying pre-generated static files

Configuration Methods

Netlify CLI looks for the publish directory in three places (in order):

1. Command Line Flag (Highest Priority)

Terminal window
netlify deploy --dir=./dist

2. Configuration File (netlify.toml)

Create netlify.toml in your project root:

[build]
publish = "dist"

3. Interactive Prompt

If not specified, Netlify CLI will ask you interactively.

Typical Workflow

Terminal window
# 1. Build your site locally
npm run build
# 2. Deploy to draft URL for testing
netlify deploy --dir=./dist
# 3. Review the draft URL, then deploy to production
netlify deploy --dir=./dist --prod

CI/CD Example (GitHub Actions)

name: Deploy to Netlify
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20'
- run: npm install
- run: npm run build
- name: Deploy to Netlify
run: netlify deploy --dir=output --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

Key Concepts

Publish Directory

The directory containing deploy-ready HTML files and assets. Specified relative to the base directory (root by default).

Base Directory

Directory where Netlify checks for dependency files (package.json, .nvmrc), installs dependencies, and runs build commands. Defaults to repository root.

Draft vs Production

  • Draft deploys: Unique preview URLs for testing (default behavior)
  • Production deploys: Deploys directly to your main site URL (use --prod)

Common Patterns

Deploy Multiple Directories

For monorepos or multiple sites:

Terminal window
# Deploy different directories
netlify deploy --dir=./packages/site-a/dist --prod
netlify deploy --dir=./packages/site-b/dist --prod

Deploy with Functions

If you have Netlify Functions:

Terminal window
netlify deploy --dir=./dist --functions=./functions --prod

Comparison: Netlify vs Cloudflare Pages

FeatureNetlify CLICloudflare Wrangler
Deploy commandnetlify deploy --dir=./distwrangler pages deploy ./dist
Draft deploys--dir (default)--branch=preview
Production--dir --prodDefault behavior
Configurationnetlify.tomlwrangler.toml or flags
Skip build--no-buildAlways skips (just uploads)

Both CLIs support direct static directory uploads!

Sources

  1. Netlify CLI Get Started
  2. Netlify Deploy Command Reference
  3. Netlify Build Configuration
  4. Deploying with GitHub Actions
  5. Netlify CLI GitHub