Skill: Edit Site
Make small changes to one of your organization's sites as one new draft. Find-and-replace edits, page removals and renames, and images attached in the chat, stored as they are or cropped and cut out.
Edit Site makes small, exact changes to a site your organization owns without resending whole files. It comes with the Web Builder. Every call writes one new draft; the live site doesn’t change until a person publishes it from Sites.
It is also the only Web skill that removes or renames a page, and the only way an image someone attaches in the chat reaches a site.
Parameters
| Parameter | Type | Description |
|---|---|---|
site_name | string | The site, as List Sites reports its site_name |
edits | array | 1 to 20 operations, applied in order. Each one sees the draft as the operations before it left it |
Operations
| Operation | Fields | What it does |
|---|---|---|
| Replace | op (replace or null), file, find, replace | Replaces find with replace in one .html, .css or .js file. find must occur exactly once in that file, is not empty, and is at most 2,048 characters. replace is at most 8,192 characters; an empty string deletes the found text |
| Remove | op: "remove", file, links_to | Removes an .html page. If the site’s own files link to it, the call refuses and lists those links, unless links_to names the page those links should point to instead |
| Rename | op: "rename", file, to | Renames an .html page and rewrites links to it in the site’s .html, .css and .js files. to uses lowercase letters, digits, ., _ and -, ends in .html, and must not exist already |
| Add image | op: "add_image", file, attachment_id | Stores an image attached in this conversation as a file of the draft. A large PNG or JPEG is stored as a smaller .webp, so pages must use the name the response gives. A name the draft already has is replaced |
| Edit image | op: "edit_image", file, source_file or attachment_id, steps | Stores an edited copy of an attached image or of an image already in the draft. The source isn’t changed. file ends in .png or .webp |
index.html can’t be removed or renamed.
Image steps. steps holds 1 to 8 steps, each applied to the result of the one before:
| Step | Effect |
|---|---|
crop | Keeps the rectangle given by left, top, width and height, each a fraction from 0 to 1 |
trim | Cuts away a uniform border |
circle | Crops to a centred square and keeps the circle inside it |
remove_background | Makes the flat background that touches the edges transparent. Colour inside the subject is kept |
keep_largest | After remove_background, keeps only the largest shape, such as a badge without the wordmark under it |
trim and remove_background take a tolerance from 0 to 100 for how far a colour may differ from the background; the default is 12.
Image types and sizes. Add image takes .jpg, .jpeg, .png, .webp, .gif, .avif, .svg and .ico names. A version can hold images and fonts of up to 5 MB each and 25 MB in total.
Behavior
- All or nothing. Every operation is applied in memory first. If one fails, nothing is written and the error names the operation that failed.
- Links. Remove and rename look for links in link positions only: HTML attributes such as
hrefandsrc, CSSurl(), and string literals in scripts. Absolute addresses with a host, such as a canonical link, aren’t checked or rewritten. - Earlier versions keep removed pages. A removed page stays in every earlier version, so the live site keeps serving it until a person publishes this draft or a later one.
- Concurrent changes. If another change lands on the draft after this call read it, the call refuses and writes nothing.
Response
| Field | Description |
|---|---|
success | true |
site_name, username | The site and its organization’s slug |
edits_applied | How many operations were applied |
edited_files | Files uploaded into the new draft: edited, link-rewritten or renamed to |
added_files | Images stored, each with its stored name, content_type and bytes; an edited image adds its width and height |
removed_files, renamed_files | Pages removed, and pages renamed |
rewritten_links | Each link a remove or rename rewrote, with its file and line |
files | The files the new draft holds |
version, live_version | The new draft’s version, and the version visitors see now |
published | Always false |
summary | A one-line account of what changed |
warning, syntax_errors, missing_files | As in Create Site |
When it refuses
- No site with that
site_namein the organization, or the site is archived. - A
findthat matches no text or more than once, a page that doesn’t exist, a rename to a name that exists, or a remove of a page that is still linked withoutlinks_to. - An image over 5 MB, or more than 25 MB of images and fonts in the version.
Related skills: Read Site | Update Site | Preview Site