Get started
Documentation menu

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 base must be /, so a GitHub Pages project site under /<repository>/ doesn’t work; use a custom domain, or the <organisation>.github.io repository.
  • Caching. admin/index.html and admin/dist/cms.js keep their names from build to build; everything under admin/dist/chunks/ and admin/dist/assets/ has a content hash in its name. If your host lets you set headers, serve the first two with Cache-Control: no-cache and 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, open http://localhost:4321/admin/, and save to the same repository as everyone else. The preview runs on the other loopback name (127.0.0.1 when the CMS is on localhost), 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 with VITE_VISUAL_PREVIEW_URL set 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 add localhost to its allowed domains so editors can sign in from astro dev too.