0
# Site Management
1
2
Core project and site management functionality for creating, linking, configuring, and managing Netlify projects and their associated resources.
3
4
## Capabilities
5
6
### Site Creation
7
8
Create new Netlify sites with various configuration options and team assignments.
9
10
```typescript { .api }
11
/**
12
* Create empty Netlify site
13
* Command: netlify sites:create [options]
14
*/
15
interface SiteCreateOptions {
16
/** Site name (max 63 characters, will be part of site URL) */
17
name?: string;
18
/** Account/team slug for site ownership */
19
accountSlug?: string;
20
/** Initialize continuous integration hooks */
21
withCi?: boolean;
22
/** Force manual CI setup instead of automatic */
23
manual?: boolean;
24
/** Create site without linking to local project */
25
disableLinking?: boolean;
26
}
27
28
/**
29
* Create site from starter template
30
* Command: netlify sites:create-template [repository] [options]
31
*/
32
interface SiteCreateTemplateOptions {
33
/** Site name (max 63 characters) */
34
name?: string;
35
/** Template repository URL */
36
url?: string;
37
/** Account/team slug for site ownership */
38
accountSlug?: string;
39
/** Initialize continuous integration hooks */
40
withCi?: boolean;
41
}
42
```
43
44
**Usage Examples:**
45
46
```bash
47
# Create site with interactive prompts
48
netlify sites:create
49
50
# Create named site
51
netlify sites:create --name my-awesome-project
52
53
# Create site for specific team
54
netlify sites:create --name team-project --account-slug my-team
55
56
# Create site with CI enabled
57
netlify sites:create --name ci-project --with-ci
58
59
# Create without linking to current directory
60
netlify sites:create --name standalone-site --disable-linking
61
62
# Create from template repository
63
netlify sites:create-template
64
65
# Create from specific template
66
netlify sites:create-template https://github.com/netlify/gatsby-starter
67
68
# Create template site with custom name
69
netlify sites:create-template --name my-gatsby-site --url https://github.com/netlify/gatsby-starter
70
```
71
72
### Site Linking
73
74
Link local projects to existing Netlify sites for deployment and management.
75
76
```typescript { .api }
77
/**
78
* Link local project to existing Netlify site
79
* Command: netlify link [projectIdOrName] [options]
80
*/
81
interface LinkOptions {
82
/** Project ID to link to */
83
id?: string;
84
/** Project name to link to */
85
name?: string;
86
/** Git remote name for linking */
87
gitRemoteName?: string;
88
}
89
90
/**
91
* Unlink local project from Netlify site
92
* Command: netlify unlink
93
*/
94
interface UnlinkOptions {
95
/** No additional options for unlink */
96
}
97
```
98
99
**Usage Examples:**
100
101
```bash
102
# Interactive site selection
103
netlify link
104
105
# Link by site ID
106
netlify link --id abc123def456
107
108
# Link by site name
109
netlify link --name my-production-site
110
111
# Link with custom git remote
112
netlify link --git-remote-name origin
113
114
# Link directly with site ID argument
115
netlify link abc123def456
116
117
# Unlink current project
118
netlify unlink
119
```
120
121
### Site Listing and Information
122
123
List and retrieve information about accessible Netlify sites.
124
125
```typescript { .api }
126
/**
127
* List all accessible sites
128
* Command: netlify sites:list [options]
129
*/
130
interface SiteListOptions {
131
/** Output as JSON */
132
json?: boolean;
133
}
134
135
/**
136
* Site information structure
137
*/
138
interface SiteInfo {
139
/** Site ID */
140
id: string;
141
/** Site name */
142
name: string;
143
/** Primary site URL */
144
url: string;
145
/** Admin URL */
146
adminUrl: string;
147
/** Site state */
148
state: 'created' | 'building' | 'deployed' | 'error';
149
/** Account information */
150
account: {
151
name: string;
152
slug: string;
153
};
154
/** Git repository information */
155
repo?: {
156
provider: 'github' | 'gitlab' | 'bitbucket';
157
owner: string;
158
name: string;
159
fullName: string;
160
url: string;
161
branch: string;
162
};
163
/** Build settings */
164
buildSettings: {
165
command?: string;
166
publishDir?: string;
167
functionsDir?: string;
168
};
169
/** Creation and update timestamps */
170
createdAt: Date;
171
updatedAt: Date;
172
/** Deployment count */
173
deployCount: number;
174
/** Custom domain information */
175
customDomain?: string;
176
/** SSL status */
177
ssl: boolean;
178
}
179
```
180
181
**Usage Examples:**
182
183
```bash
184
# List all sites
185
netlify sites:list
186
187
# List sites with JSON output
188
netlify sites:list --json
189
```
190
191
### Site Deletion
192
193
Permanently delete Netlify sites with confirmation prompts.
194
195
```typescript { .api }
196
/**
197
* Delete a site permanently
198
* Command: netlify sites:delete <id> [options]
199
*/
200
interface SiteDeleteOptions {
201
/** Force deletion without confirmation prompt (useful for CI) */
202
force?: boolean;
203
}
204
```
205
206
**Usage Examples:**
207
208
```bash
209
# Delete site with confirmation prompt
210
netlify sites:delete abc123def456
211
212
# Force delete without prompt (for CI/scripts)
213
netlify sites:delete abc123def456 --force
214
```
215
216
### Project Initialization
217
218
Initialize continuous deployment for new or existing projects.
219
220
```typescript { .api }
221
/**
222
* Configure continuous deployment for project
223
* Command: netlify init [options]
224
*/
225
interface InitOptions {
226
/** Manual git remote configuration */
227
manual?: boolean;
228
/** Custom git remote name */
229
gitRemoteName?: string;
230
}
231
232
/**
233
* Project initialization configuration
234
*/
235
interface ProjectInitConfig {
236
/** Git repository detection */
237
gitRepo: {
238
detected: boolean;
239
provider?: 'github' | 'gitlab' | 'bitbucket';
240
owner?: string;
241
name?: string;
242
branch: string;
243
remoteUrl: string;
244
};
245
246
/** Build configuration detection */
247
buildConfig: {
248
/** Detected framework */
249
framework?: 'gatsby' | 'next' | 'react' | 'vue' | 'angular' | 'hugo' | 'jekyll';
250
/** Detected build command */
251
buildCommand?: string;
252
/** Detected publish directory */
253
publishDir?: string;
254
/** Detected functions directory */
255
functionsDir?: string;
256
};
257
258
/** Site connection options */
259
siteOptions: {
260
/** Create new site */
261
createNew: boolean;
262
/** Link to existing site */
263
linkExisting?: {
264
siteId: string;
265
siteName: string;
266
};
267
};
268
}
269
```
270
271
**Usage Examples:**
272
273
```bash
274
# Initialize with automatic detection
275
netlify init
276
277
# Initialize with manual git configuration
278
netlify init --manual
279
280
# Initialize with custom git remote name
281
netlify init --git-remote-name upstream
282
```
283
284
### Site Status and Information
285
286
Get detailed status information about linked or specified sites.
287
288
```typescript { .api }
289
/**
290
* Print status information
291
* Command: netlify status [options]
292
*/
293
interface StatusOptions {
294
/** Include verbose system information */
295
verbose?: boolean;
296
/** Output as JSON */
297
json?: boolean;
298
}
299
300
/**
301
* Site status information
302
*/
303
interface SiteStatus {
304
/** Current user information */
305
user: {
306
name: string;
307
email: string;
308
avatar: string;
309
teams: Array<{
310
name: string;
311
slug: string;
312
role: 'owner' | 'collaborator' | 'developer';
313
}>;
314
};
315
316
/** Site information (if linked) */
317
site?: {
318
id: string;
319
name: string;
320
url: string;
321
adminUrl: string;
322
state: string;
323
account: {
324
name: string;
325
slug: string;
326
};
327
buildSettings: {
328
command?: string;
329
publishDir?: string;
330
functionsDir?: string;
331
};
332
lastDeploy?: {
333
id: string;
334
state: string;
335
url: string;
336
createdAt: Date;
337
};
338
};
339
340
/** Git repository information */
341
git?: {
342
provider: string;
343
owner: string;
344
repo: string;
345
branch: string;
346
commitSha: string;
347
remoteUrl: string;
348
};
349
350
/** Local configuration */
351
config: {
352
/** Netlify configuration file path */
353
configPath?: string;
354
/** Functions directory */
355
functionsDir?: string;
356
/** Publish directory */
357
publishDir?: string;
358
/** Build command */
359
buildCommand?: string;
360
};
361
}
362
```
363
364
**Usage Examples:**
365
366
```bash
367
# Basic status information
368
netlify status
369
370
# Verbose status with system info
371
netlify status --verbose
372
373
# Status as JSON
374
netlify status --json
375
```
376
377
### Site Configuration Management
378
379
Manage site settings and configuration options.
380
381
```typescript { .api }
382
/**
383
* Site configuration settings
384
*/
385
interface SiteConfig {
386
/** General settings */
387
general: {
388
name: string;
389
customDomain?: string;
390
defaultBranch: string;
391
httpsRedirect: boolean;
392
ssl: {
393
enabled: boolean;
394
certificateType: 'netlify' | 'custom' | 'lets-encrypt';
395
};
396
};
397
398
/** Build settings */
399
build: {
400
command?: string;
401
publishDirectory?: string;
402
functionsDirectory?: string;
403
baseDirectory?: string;
404
packageDirectory?: string;
405
stopBuilds: boolean;
406
};
407
408
/** Environment settings */
409
environment: {
410
variables: Record<string, string>;
411
secrets: string[];
412
};
413
414
/** Deploy settings */
415
deploy: {
416
autoPublish: boolean;
417
branchDeploys: boolean;
418
deployPreviews: boolean;
419
splitTesting: boolean;
420
};
421
422
/** Security settings */
423
security: {
424
mixedContent: 'block' | 'upgrade';
425
referrerPolicy: string;
426
featurePolicy: string;
427
permissions: string[];
428
};
429
430
/** Performance settings */
431
performance: {
432
assetOptimization: boolean;
433
bundleAnalysis: boolean;
434
prerendering: boolean;
435
};
436
}
437
```
438
439
### Team and Account Management
440
441
Handle multi-team workflows and account switching.
442
443
```typescript { .api }
444
/**
445
* Switch between Netlify accounts/teams
446
* Command: netlify switch
447
*/
448
interface SwitchOptions {
449
/** No additional options for switch */
450
}
451
452
/**
453
* Team/account information
454
*/
455
interface TeamInfo {
456
/** Team ID */
457
id: string;
458
/** Team name */
459
name: string;
460
/** Team slug */
461
slug: string;
462
/** User's role in team */
463
role: 'owner' | 'collaborator' | 'developer';
464
/** Team plan */
465
plan: 'starter' | 'pro' | 'business' | 'enterprise';
466
/** Team members count */
467
memberCount: number;
468
/** Sites count */
469
siteCount: number;
470
/** Team settings */
471
settings: {
472
billingEmail: string;
473
defaultDomain: string;
474
customBranding: boolean;
475
};
476
}
477
```
478
479
**Usage Examples:**
480
481
```bash
482
# Interactive team/account switching
483
netlify switch
484
```
485
486
### Site Hooks and Integrations
487
488
Manage webhooks and integrations for sites.
489
490
```typescript { .api }
491
/**
492
* Print hook information for linked site
493
* Command: netlify status:hooks
494
*/
495
interface HooksInfo {
496
/** Deployment hooks */
497
deployHooks: Array<{
498
id: string;
499
title: string;
500
url: string;
501
branch: string;
502
createdAt: Date;
503
}>;
504
505
/** Outgoing webhooks */
506
webhooks: Array<{
507
id: string;
508
event: 'deploy-building' | 'deploy-succeeded' | 'deploy-failed' | 'deploy-locked' | 'deploy-unlocked';
509
url: string;
510
enabled: boolean;
511
}>;
512
513
/** Git provider integration */
514
gitIntegration: {
515
provider: 'github' | 'gitlab' | 'bitbucket';
516
installationId: string;
517
connected: boolean;
518
permissions: string[];
519
};
520
521
/** Third-party integrations */
522
integrations: Array<{
523
name: string;
524
type: 'analytics' | 'monitoring' | 'forms' | 'identity';
525
enabled: boolean;
526
settings: Record<string, any>;
527
}>;
528
}
529
```
530
531
**Usage Examples:**
532
533
```bash
534
# Show hooks information for current site
535
netlify status:hooks
536
```