# CLI: Static Sites

Deploy and manage static sites using the DanubeData CLI.

## Prerequisites

- [DanubeData CLI installed](https://docs.danubedata.ro/cli-overview)
- Authenticated via `danube login` or `DANUBE_TOKEN`

## Quick start

Deploy a static site in 3 commands:

```bash
# 1. Link your project directory to a site
danube pages link

# 2. Deploy
danube pages deploy
```

That's it. Your site is live.

## Linking a project

Before deploying, link your local directory to a DanubeData static site:

```bash
danube pages link
```

The CLI prompts you to:

1. Select a team (if you belong to multiple)
2. Choose an existing site or create a new one

This creates `.danube/project.json` in your project directory with the site ID and team ID.

### Headless linking (CI/CD)

Skip interactive prompts by setting environment variables:

```bash
export DANUBE_SITE_ID="42"
export DANUBE_TEAM_ID="1"
```

## Deploying

### Basic deploy

```bash
danube pages deploy
```

Deploys the current directory. The CLI:

1. Packages all files into a ZIP (excluding `.git`, `node_modules`, `.danube`, `.gitignore` patterns)
2. Uploads the ZIP to DanubeData
3. Polls the build status until completion (or timeout after 5 minutes)

### Deploy a specific directory

```bash
danube pages deploy --dir ./dist
```

Useful for framework builds where the output is in a subdirectory.

### Deploy without waiting

```bash
danube pages deploy --no-wait
```

Uploads the files and exits immediately without waiting for the build to complete.

### Using danube.json

Create a `danube.json` in your project root to configure the default deployment directory and exclude patterns:

```json
{
  "outputDir": "dist",
  "ignore": ["*.map", "test/**", "*.test.js"]
}
```

With this in place, `danube pages deploy` automatically deploys the `dist/` directory.

### Framework examples

**React (Vite):**
```bash
npm run build
danube pages deploy --dir ./dist
```

**Next.js (static export):**
```bash
npx next build
danube pages deploy --dir ./out
```

**Vue:**
```bash
npm run build
danube pages deploy --dir ./dist
```

**Astro:**
```bash
npm run build
danube pages deploy --dir ./dist
```

**Hugo:**
```bash
hugo
danube pages deploy --dir ./public
```

**Plain HTML:**
```bash
danube pages deploy
```

## Deployments

### List deployments

```bash
danube pages deployments ls
```

Shows all deployments with revision number, status, trigger type, and timestamps.

### Roll back

```bash
danube pages deployments rollback 3
```

Activates deployment revision 3. The rollback is instant — no rebuild required.

## Custom domains

### List domains

```bash
danube pages domains ls
```

Shows all domains with their type (default/custom), status, and verification date.

### Add a domain

```bash
danube pages domains add www.example.com
```

The CLI returns DNS verification instructions. You need to:

1. Add a DNS TXT record: `_danubedata-verify.www.example.com` with the provided token
2. Verify the domain: `danube pages domains verify www.example.com`
3. Add a CNAME record pointing `www.example.com` to your site's default domain

### Verify a domain

```bash
danube pages domains verify www.example.com
```

Triggers a DNS lookup to verify ownership. Run this after adding the TXT record.

### Remove a domain

```bash
danube pages domains remove www.example.com
```

## Complete workflow example

```bash
# Install the CLI
npm install -g @danubedata/cli

# Authenticate
danube login

# Navigate to your project
cd my-website

# Build your site (if using a framework)
npm run build

# Link to a DanubeData static site
danube pages link

# Deploy
danube pages deploy --dir ./dist

# Add a custom domain
danube pages domains add www.mysite.com

# Check deployment status
danube pages deployments ls
```

## Next steps

- [CLI Overview](https://docs.danubedata.ro/cli-overview) — Installation, auth, and configuration
- [CLI: Serverless Containers](https://docs.danubedata.ro/cli-serverless) — Container deployment commands
- [Static Sites overview](https://docs.danubedata.ro/static-sites) — Full product reference
- [Build with AI](https://docs.danubedata.ro/static-sites-ai) — Generate a site with an LLM and deploy via CLI

---

**Questions?** Contact support at support@danubedata.ro
