Your agent wrote the website. Here’s how to put the files in a DigitalOcean Spaces bucket, serve them on your own domain, and connect Surreal CMS so your client can edit them.
Spaces is a good home for a static website if you already use DigitalOcean. The bucket stores the files and serves them at its own address, a small Cloudflare Worker puts your domain in front of it, and Surreal CMS writes to the bucket when someone publishes. It doesn’t matter if the files came from Claude Code, another coding agent, or you wrote them by hand. You just need a folder of HTML, CSS, and images.
The Spaces guide in the docs has every click in the control panel and the full Worker. This post takes you from that folder to a live, editable website, and covers a few things the guide doesn’t: getting the files into the bucket from the command line, keeping your key separate from Surreal CMS’s, and changing the site later without losing your client’s edits.
Before you start
You need a DigitalOcean account. Your first bucket starts a Spaces subscription, which is $5 a month. Your
domain has to be an Active zone on a Cloudflare account, because the Worker that serves
your homepage at / runs there. The free Cloudflare plan is fine. Plan on one bucket per
website. Every file Surreal CMS publishes is public, so nothing private goes in it.
You’ll also need s3cmd, a command line tool DigitalOcean documents
for Spaces. It uploads a whole folder at once, where the control panel takes fewer than a hundred files at
a time, and it lets your agent do the work. On a Mac, brew install s3cmd does it, or ask your
agent to install it.
Get the folder ready
Look over the folder before you upload it.
-
index.htmlis at the top level, and every folder that should open at its own address, like/blog/, has anindex.htmlof its own. Links to those folders end with a slash,/blog/. Without it, the Worker won’t find the page. -
There’s an
uploadsfolder holding the images your client will change, and nothing else. This becomes the site’s upload folder, the one place editors can add, rename, and delete files. Put at least one file in it, because empty folders don’t get uploaded. Here’s why it should be a folder of its own. - There’s a
404.htmlif you want a custom not-found page. The Worker serves it. -
Stylesheets, scripts, and images are linked with relative paths or over
https://. The editor runs on a secure connection and won’t load stylesheets or scripts served over plain HTTP. -
The folder holds only the website. Agents often leave a
.gitfolder, aCLAUDE.md, or an.envfile next to the pages, and everything you upload becomes public.
If the agent hasn’t made the site editable yet, this is the time. Everything after this step touches the live files.
Read https://www.surrealcms.com/skills/surreal-cms/SKILL.md and make this website editable in Surreal CMS. Keep the images my client will change in an uploads folder, and run the checker on every page.
Create the bucket and two keys
In the control panel, open Spaces Object Storage and create a bucket in the region
closest to most of your visitors. Choose Standard Storage, leave the CDN
disabled because Cloudflare takes its place, and pick a name like my-website. The
region, name, and storage type can’t be changed later. Note the origin endpoint on the bucket’s Files tab,
something like https://my-website.nyc3.digitaloceanspaces.com. The part after the bucket
name, nyc3 here, is the region. It goes into s3cmd’s endpoint settings and into Surreal CMS’s
Region field. The docs walk through the form and
the one setting to check afterwards, Restrict File Listing.
Then open the Access Keys tab and create two keys, each with
Limited access and Read/Write/Delete permission on this one bucket. Name
one surreal-cms and the other after your computer. Surreal CMS gets the first. The second
stays on your machine for s3cmd and for your agent. Either can be deleted without touching the other, and
neither can see your other buckets or change this one’s settings. Copy each secret when it’s shown,
because it won’t be shown again.
Upload the files with s3cmd
Run s3cmd --configure s3://my-website once, with your bucket name, and answer the prompts
with the second key. Naming the bucket matters. Without it, s3cmd tests the key by listing all of your
buckets, which a limited key isn’t allowed to do, and the test fails. The
values DigitalOcean documents
are the access key and secret, US for the default region, your region’s endpoint for the S3
endpoint, the bucket template with the same region, and yes to HTTPS. For a bucket in nyc3,
that’s:
Default Region [US]: US
S3 Endpoint: nyc3.digitaloceanspaces.com
DNS-style bucket+hostname:port template for accessing a bucket: %(bucket)s.nyc3.digitaloceanspaces.com
Use HTTPS protocol: Yes
Press Enter for the encryption password, the GPG program, and the proxy. Answer Y to test the
settings and y to save them. The key ends up in ~/.s3cfg, so you never have to
paste it anywhere else, including your chat with the agent. Now sync the folder up. Add
--dry-run to the end of the command for a trial run that lists what would change, then run it
for real.
s3cmd sync ./site/ s3://my-website/ --acl-public --no-mime-magic --no-preserve --add-header=Cache-Control:no-cache
A few things about that command. The trailing slashes tell s3cmd to sync the contents of the folder into
the root of the bucket, not the folder itself. --acl-public matters because files in a Spaces
bucket are private by default and visitors can’t load a private file. Surreal CMS makes every file it
publishes public, and this does the same for yours. --no-mime-magic makes s3cmd set each
file’s type from its extension. Left to itself, it sniffs the contents instead and labels stylesheets as
plain text, which browsers refuse to apply. --no-preserve keeps it from attaching your
computer’s username to every public file. And the header gives your files the same
no-cache rule Surreal CMS puts on every file it publishes. Cloudflare caches stylesheets,
scripts, and images that come through the Worker, and that header tells it to check the bucket each time,
so a replaced file shows up right away instead of when the cache expires. Without a
--delete-removed flag, sync never removes anything from the bucket.
Check the result by opening https://my-website.nyc3.digitaloceanspaces.com/index.html with
your own bucket name and region. You should see your homepage, unstyled or not depending on how it links
its stylesheet. If you see an error, the file is probably still private.
If you’d rather have the agent do it, tell it the bucket and what not to do.
s3cmd is configured for my DigitalOcean Spaces bucket, my-website. Sync the ./site folder into the root of the bucket with s3cmd sync, --acl-public, --no-mime-magic, --no-preserve, and the header Cache-Control: no-cache. Do a dry run first and show me the list. Never pass --delete-removed.
Put it on your domain
On a custom domain, Spaces will serve /index.html but not /. Something has to
sit in front of the bucket to fill in the file name, and in this setup that’s a Cloudflare Worker. Copy
the Worker from the docs, change its first line
to your bucket’s origin endpoint with no slash at the end, deploy it, and add your hostname as a custom
domain in the Worker’s settings. Cloudflare creates the DNS record and the certificate. If the hostname
already has a CNAME record, delete that first. The Worker serves index.html for folder paths,
shows your 404.html when a file is missing, and can hide .html extensions if you
turn that on.
Once the domain is active, https://www.example.com/ loads your homepage. If you want the apex
domain and www both to work, add each one to the Worker.
Let the editor load your fonts
Surreal CMS opens your page inside its own app to edit it, so the page runs on a different origin than it
does for a visitor, and its requests for web fonts and JavaScript modules become cross-origin. Browsers
block those unless the server allows them. Without that permission, the editor shows your site in a
fallback font, and any type="module" script stays silent. Visitors aren’t affected.
The Worker in the docs takes care of this. Its last lines copy the bucket’s response and add the header that grants permission, which is what a public website already permits anyway.
const result = new Response(response.body, response);
result.headers.set('Access-Control-Allow-Origin', '*');
return result;
If you set up the Worker before those lines were added, paste the current version in and deploy it again.
You can check with curl, using the path of a font your site loads. A missing file returns the
404 page without the header, so the path has to be right.
curl -s -o /dev/null -D - https://www.example.com/fonts/body.woff2 | grep -i access-control-allow-origin
Connect Surreal CMS
Log in, choose New Site, and pick
DigitalOcean Spaces as the protocol. The URL is your own domain,
https://www.example.com/, not the digitaloceanspaces.com endpoint. Enter the
region, nyc3 in this example, the bucket name, and the key you set aside for Surreal CMS.
Leave the home folder empty, since the site is at the root of the bucket, and set the upload folder to
uploads. Select Test Connection. The
docs describe each field.
Then open Enable Pages and use Scan for Pages. It finds every file with content regions and lets you enable them at once. Open one in the editor, change a word, publish, and reload the page on your domain. The change should be there right away. Surreal CMS writes the file straight to the bucket, and Cloudflare doesn’t cache HTML by default.
On a paid plan, your agent can do this part with an agent token: create the site, enable the pages, and invite your client. Creating the site through the API means giving the agent the Surreal CMS key, so if you’d rather keep that out of the chat, let it create the site without credentials and enter the keys yourself under Edit Site. The API can’t test the connection or publish, so you’ll still do those yourself.
Change the site later
Once a client is editing, the bucket is the only current copy of the site. The folder on your computer is out of date the moment they publish. So before you or the agent change anything, pull the live site down into a new, empty folder. An empty folder matters: if you pull into the old one, files your client deleted are still there and go back up with the next push.
s3cmd sync s3://my-website/ ./site/
Make the change, then sync the folder back up with the same command you used the first time, and read the
--dry-run list before the real run. s3cmd compares each file’s size and checksum, so the list
should name only the files you changed. If it lists a page you didn’t touch, the client published in the
meantime, so pull again. Pull right before you push, and if the client is working on the site, ask them to
hold off until you’re done. Never add --delete-removed when you push. It removes everything
from the bucket that isn’t in your folder, including your client’s uploads. If a page needs to go, remove
it in Surreal CMS first so it isn’t left pointing at a missing file, then delete the file in the control
panel if it’s still there.
The agent prompt is the same idea.
Pull the live site from s3://my-website/ into a new, empty ./site/ folder with s3cmd sync before you change anything. Then add a Services page that matches the other pages, run the Surreal CMS checker, and sync the folder back up with --acl-public, --no-mime-magic, --no-preserve, and Cache-Control: no-cache. Never pass --delete-removed.
A few more habits. Don’t overwrite a page the client has edited with an old copy, and don’t delete a page in Surreal CMS and add it again. The first throws away their edits, the second the page’s revision history too. When you add a page, keep its header and footer identical to the other pages, because Surreal CMS copies shared includes to every enabled page when one is published, and a page with a stale copy overwrites the rest. Then enable the new page under Enable Pages, and add it to your client’s permissions if they’re limited to specific pages.
What it costs
The Spaces subscription is $5 a month and covers all of your buckets, with storage and transfer allowances a brochure website won’t come close to. On the Cloudflare side, every request to your site runs the Worker, and the free Workers plan allows 100,000 requests a day. A busy or image-heavy site needs the paid plan. The docs have the current numbers.
Checklist
-
A folder with
index.htmlat the top, anuploadsfolder, nothing private, and clean checker results - One bucket for this website, Standard Storage, CDN off, file listing restricted
- Two limited access keys with Read/Write/Delete on the bucket: one for Surreal CMS, one for you
-
Files synced up with s3cmd,
--acl-public,--no-mime-magic,--no-preserve, andCache-Control: no-cache /index.htmlloading from the origin endpoint- The Worker from the docs on your hostname, with your origin endpoint in its first line
-
Surreal CMS connected with the
surreal-cmskey anduploadsas the upload folder - A test edit published and visible on the domain
- Pull into an empty folder before every push, and never
--delete-removed
When everything works, hand it off. If you get stuck, contact us and tell us where it stopped.