Guides
Deployment
Publish the static site and the CMS, and decide where the live preview runs.
The site and the CMS
astro build writes a fully static site to dist/, as without the editor. The integration adds the CMS to it at dist/admin/. Deploy dist/ to any static host: GitHub Pages, Cloudflare, Netlify, your own server. This website is built by a GitHub Actions workflow and served by GitHub Pages.
- Serve it from the root. The site’s
basemust be/, so a GitHub Pages project site under/<repository>/doesn’t work; use a custom domain, or the<organisation>.github.iorepository. - Caching.
admin/index.htmlandadmin/dist/cms.jskeep their names from build to build; everything underadmin/dist/chunks/andadmin/dist/assets/has a content hash in its name. If your host lets you set headers, serve the first two withCache-Control: no-cacheand the hashed files for as long as you like. Otherwise editors may keep an old CMS until the host’s cache expires. - Rebuilds. Saves in the CMS are commits to your repository. Let your host rebuild on every push to the branch Sveltia saves to.
The live preview
The preview renders .astro components, so it needs a server. There are two ways to have one:
- Locally, with
astro dev(the usual way). Editors run the site on their machine, openhttp://localhost:4321/admin/, and save to the same repository as everyone else. The preview runs on the other loopback name (127.0.0.1when the CMS is onlocalhost), so it can never read the CMS’s session. - A standalone preview service (
service: true, needs@astrojs/node). It builds the preview as a Node server you run on its own hostname, so editors can use the deployed CMS with a live preview. The CMS is then built withVITE_VISUAL_PREVIEW_URLset to that server, and the server is told which CMS origins to accept. The details are in the architecture notes.
On a deployed /admin without a preview service, the visual editor still offers the block structure and the inspector, and the preview pane says how to start the service.
Signing in on the deployed CMS
Sveltia signs people in with the backend in config.yml. For a GitHub repository:
- An access token works with no setup: Sveltia’s sign-in page offers it.
- Sign in with GitHub needs an OAuth app and an authenticator; see Sveltia’s backend docs.
- Sveltia CMS Additions runs on a free Cloudflare Worker and gives you usernames, passwords and roles, so editors don’t need GitHub accounts. Deploy it, run its setup wizard from your
/admin, and addlocalhostto its allowed domains so editors can sign in fromastro devtoo.