Skip to content

From an existing Astro site

Use with AI

This page

Ask ClaudeAsk ChatGPT

All of CaraCMS Docs

Connect once, and it answers your questions from this help.

Connect to ClaudeConnect to ChatGPT

An Astro site moves onto CaraCMS one page at a time. The pages you haven’t moved keep working as they are, so the site can be deployed at any point along the way.

Read Porting a site first for the shape of the work.

Before you start

  • The site is on Astro 7 and Node 22.12 or later.
  • You’ve decided where it will run: CaraCMS Cloud or Standalone.
  • The site’s own tests pass, and you’ve noted which do.

The order

  1. Install the package, commit the install, and run caracms init. Getting started has the commands.

  2. Set up the comparison: a git worktree at the commit before init, built and served on its own port.

  3. Write the page component from the site’s layout. It takes over the head, the header and the footer.

  4. Convert a page: its sections become blocks, its content becomes a JSON file, and its old route file goes. One page per commit.

  5. Compare that page with the old site before moving to the next.

  6. Move the images into the site’s media.

  7. Convert the content collections.

  8. Move the header, the footer and the site’s settings.

  9. Run the checks, then the editor walk.

Terminal window
git worktree add ../my-site-baseline <commit before init>

Converting a page

Each section component becomes a block: a config entry with a field for each thing an editor would change, and a component that renders the same elements and classes as before.

  • Reuse a block across pages where the sections are the same. Don’t make one block per page.
  • Things that aren’t content stay in the component: an animation’s settings, a decorative shape.
  • A card’s icon becomes an image field, so a designer can swap it.

Images

Images kept in the repo are uploaded to the site’s media, and the content then names each by its key:

Terminal window
npx caracms media import src/assets/*.jpg

The site needs its media credentials in .env for this, and to show images in the dev server.

Collections

An Astro content collection becomes a CaraCMS collection: Markdown or YAML entries become JSON documents, and the collection’s route file goes, since the catch-all route serves them.

Before the pull request

  1. caracms validate reports no errors.

  2. The site builds.

  3. The site’s own tests pass as they did before.

  4. Every converted page matches the old site.

  5. A new page made in the editor, from the general blocks, comes out right with no code.

  6. Every visible word opens a field, and the audit is quiet.

For your agent

The caracms-adopt skill, copied into the site by init, is the full method: the comparison script and its options, converting each kind of page, forms, scripts under the preview, and the editor walk.