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

ParameterTypeDescription
site_namestringThe site, as List Sites reports its site_name
editsarray1 to 20 operations, applied in order. Each one sees the draft as the operations before it left it

Operations

OperationFieldsWhat it does
Replaceop (replace or null), file, find, replaceReplaces 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
Removeop: "remove", file, links_toRemoves 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
Renameop: "rename", file, toRenames 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 imageop: "add_image", file, attachment_idStores 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 imageop: "edit_image", file, source_file or attachment_id, stepsStores 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:

StepEffect
cropKeeps the rectangle given by left, top, width and height, each a fraction from 0 to 1
trimCuts away a uniform border
circleCrops to a centred square and keeps the circle inside it
remove_backgroundMakes the flat background that touches the edges transparent. Colour inside the subject is kept
keep_largestAfter 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 href and src, CSS url(), 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

FieldDescription
successtrue
site_name, usernameThe site and its organization’s slug
edits_appliedHow many operations were applied
edited_filesFiles uploaded into the new draft: edited, link-rewritten or renamed to
added_filesImages stored, each with its stored name, content_type and bytes; an edited image adds its width and height
removed_files, renamed_filesPages removed, and pages renamed
rewritten_linksEach link a remove or rename rewrote, with its file and line
filesThe files the new draft holds
version, live_versionThe new draft’s version, and the version visitors see now
publishedAlways false
summaryA one-line account of what changed
warning, syntax_errors, missing_filesAs in Create Site

When it refuses

  • No site with that site_name in the organization, or the site is archived.
  • A find that 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 without links_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