Skill: Create Site
Create a new site for your organization from HTML, CSS, JavaScript and extra pages. The first version is saved as an unpublished draft unless the person asked to publish now.
Create Site builds a new site for your organization from the HTML, CSS and JavaScript the Web Builder writes. By default the first version is an unpublished draft that a person publishes from Sites.
Parameters
The Web Builder sends every parameter on every call.
| Parameter | Type | Description |
|---|---|---|
site_name | string | The site’s slug. It is lowercased, every character outside a-z, 0-9 and - becomes -, runs of - collapse and the ends are trimmed, so “My Site” becomes my-site. At most 63 characters. Refused if no letter or digit is left |
description | string | One line describing the site, shown under its name on the Sites list. Required |
html | string | The full index.html. Required and not empty |
css | string | The full stylesheet, or "" for none |
js | string | The full script, or "" for none |
pages | array or null | Extra pages beyond index.html, each { filename, html }, or null for none. Each filename is lowercased, any character outside a-z, 0-9, ., _ and - becomes -, and it must end in .html |
draft | boolean | true saves the first version unpublished. false makes the site live as soon as the call returns. The Web Builder passes true unless the person has explicitly asked to publish now |
What it writes
index.html, each extra page,styles.csswhencssisn’t empty, andscript.jswhenjsisn’t empty. If a page has no tag loadingstyles.cssorscript.js, the skill adds it.- One site record owned by the calling organization.
- The site’s subdomain, which is its
site_name.
Response
| Field | Description |
|---|---|
success | true |
url | Where the site is served. On a draft it doesn’t serve anything until a person publishes |
site_name | The slug the site was saved under |
subdomain | The site’s subdomain |
organization | The organization’s slug |
files | The files written |
description | The description saved |
published, status, version, live_version, message | Only on a draft: false, not_published, 1, null, and a message saying the address doesn’t show the site until someone publishes it |
warning, syntax_errors, missing_files | Present when a script won’t run in the browser, or a page links to a file the site doesn’t have. Up to 10 of each are listed, with totals |
When it refuses
| Situation | Result |
|---|---|
The organization already has a site with this site_name | An error saying to use Update Site. Create Site never overwrites a site |
| The subdomain is reserved, or another site on Horizon already has it | success: false, error SUBDOMAIN_RESERVED or SUBDOMAIN_TAKEN, and suggested_subdomain when one is free. Nothing is created |
A required parameter is missing, or draft isn’t true or false | An error naming the parameter. Nothing is written |
Subdomains are unique across every organization on Horizon, so a common name can already be taken even when your organization has no site by that name.
Related skills: Update Site | Edit Site | Import Design | List Sites