Bring In a Website (Planned)
Preview, bring in, or check a website's content from a file (action sites.content.import) brings a website's pages, posts, docs, redirects, and menus in from a JSON file. It is the same for every account.
Steps
- Preview counts everything and checks it. It writes nothing. It also tells you how many product names the pages show prices for are found in your Products.
- Bring In adds what is not there yet. Every id in the file is kept, so a second Bring In adds nothing, and a page you edited since is never overwritten. If anything in the file is wrong, nothing is added.
- Check compares the website with the file by count and by id, and names anything missing.
Brought in pages are ready, and the website is not published until a person publishes it. Owners, admins, and anyone whose role allows managing websites can do this.
The Stylesheet
A website's whole stylesheet can come in with the file. Add a stylesheet field holding the CSS as text:
{ "site": { "id": "acme-test", "name": "Acme Test Co" }, "pages": [ ... ], "stylesheet": ".hero{color:var(--accent)}" }
- It becomes the website's theme stylesheet, in a theme made for that website (named after it, for example Acme Test Co Theme) when the website has no theme yet. A website that already has a theme keeps it and its stylesheet exactly as they are, so a stylesheet you edited is never overwritten.
- It is checked and cleaned the same way as a stylesheet you save in Themes, and saved compact (no added spaces or line breaks, so cleaning never makes it longer). An import of another style sheet, an outside address, or a script is removed, and a small picture written in as a
data:address (SVG, PNG, JPEG, GIF, WebP, or AVIF, up to 65,536 characters each) is kept. The limit is 1,000,000 characters, checked once on the cleaned text that is saved. A stylesheet that is not text is refused. Nothing is added if anything in the file is wrong. - The whole file is still limited to the size above, so a stylesheet too big for one file is saved with the theme stylesheet action instead (Section and Stylesheet Tools).
- Preview reports the stylesheet's size as it will be saved (after cleaning), the limit, how many parts are removed and the first 50 with the reason for each, and whether the website already has one. Bring In saves exactly what Preview reported, so a stylesheet Preview accepts is never refused for size. Check confirms the website has its stylesheet. A second Bring In changes nothing.
- Visitors get it as its own file that browsers keep (Themes, Stored Builds), so a stylesheet of a real, already minified website fits without being split up.
Redirects in the File
Each redirect has a from address, a to address, and an optional code (301 or 302). An id is optional. A redirect with no id gets one made from its from address: every character that is not a letter, number, or . _ : - becomes _, so /cart/ is _cart_ and /cart is _cart. If two come out the same, the later one gets a number, and an id is cut to 80 characters. The same file always makes the same ids, so Bring In skips redirects that are already there. /cart/ and /cart are the same address, so only the first of them is added.
How Big a File Can Be
A file can hold up to about 522,240 characters (a little over 500 KB of text). The API and the MCP accept a request of at most 1 MiB, and the file travels inside it with every quote, backslash, and line break written as two characters, so this is the biggest file that always arrives. A file with many accented or non-English characters counts by its size as sent, so it may need to be a little smaller.
A bigger website goes in as several files. Give every file the same site id and put a share of the pages in each one, then Preview and Bring In each file. Bring In skips what is already there, so the files can come in any order and a file can be sent again safely. Check each file the same way. A file that is too big is refused before anything is read, with the limit and these steps, and nothing is added.
A Bundle Made by a Script
The file is plain data, so a script can write it. A page can hold a Published Tool block (Published Tools on Your Pages) by naming the published action in the block's tool field, and a redirect keeps an old address working by sending it to the new one. A script that writes a bundle never needs the account: it reads its own source and writes only the file it is asked to. Nothing in the bundle is run until a person brings it in and publishes the website.
A Website in the Trash
If the website a file brought in has been moved to the trash, Preview says so: "A website brought in from this file is in the trash. Bring In makes a new website; restore the old one instead if you want it back." Bring In then makes a new website from the file, with every page, post, doc, redirect, menu, global, and the stylesheet. Its short name is the file's, or the first free one with a number after it, such as acme-test-2. The trashed website is never changed. A second Bring In adds nothing, and Check compares the new website with the file.
Where to Find It
Websites, then Website Registry. Preview, Bring In, and Check are for a website's content from a file. Owners and admins see it.