← Back to the blog

Guides

Astro CMS: How We Added Sveltia CMS to Our Studio Site

How we added Sveltia CMS to hashk.xyz, our Astro studio site, so pages, projects and services are edited in forms and saved to Git.

Share
In this post
  1. Quick answer
  2. Why we picked a Git-based CMS for Astro
  3. Step 1: get every piece of text into content collections
  4. Step 2: add the admin page
  5. Step 3: describe the collections in config.yml
  6. Step 4: check the config before you deploy
  7. What else we had to change in the Astro site
  8. Signing in and editing the live site
  9. When Sveltia CMS is not the right Astro CMS
  10. FAQ
The hashk.xyz home page beside the Sveltia CMS sign-in screen

We needed an Astro CMS for hashk.xyz, the site for Hashk Studio, our independent web and software studio. Our themes and templates are published as Tortoiz Themes, which is this store, but the studio site is its own project: a static Astro site with case studies, services and a handful of pages.

We picked Sveltia CMS, a free Git-based CMS, and put it at /admin/. Below is the setup we ended up with: what we changed in the site first, the config, and the parts that broke along the way. If you want a CMS for Astro without a database or a server, it should save you a few detours.

Quick answer

  • A Git-based CMS for Astro is a form editor that reads and writes the Markdown and YAML files your content collections already use. Nothing is stored anywhere else.
  • You add two files in public/admin/: an index.html that loads Sveltia CMS and a config.yml that describes your collections.
  • Sveltia can only edit what lives in content files. Text written into templates has to move into the collections first.
  • Editors sign in with a GitHub personal access token. If you have no OAuth server, set auth_methods: [token] so the login screen does not offer a button that cannot work.
  • Each save is a commit to your branch, and your host rebuilds the site from it.
  • The thing that caught us out: files you add to a collection also show up in anything else built from that collection, such as a sitemap.
The hashk.xyz home page in dark mode: the words hashk studio in large type above a row of project screenshots
hashk.xyz, an Astro site whose text, projects and services are now edited in Sveltia CMS.

Why we picked a Git-based CMS for Astro

hashk.xyz is fully static. It is built with Astro and set to output: 'static', hosted on Cloudflare Workers static assets, and Cloudflare builds it from the main branch on GitHub on every push. There is no server to run and no database to back up.

The content was already in the right shape for a Git-based CMS. It sits in Astro content collections with zod schemas in src/content.config.ts: pages (six Markdown files for home, work, services, about, contact and the 404 page), work (18 project case studies) and services (five services). A CMS that edits those files and commits them fits the way the site already deploys.

We also wanted something that is free and open source. Sveltia CMS is MIT licensed and left beta as v5.0.0 on 26 November 2026. Version 5.2.0 was the current release on npm when we set this up. For what Sveltia is and what v5 changed, see our earlier post on adding Sveltia CMS to a Jekyll theme. If you are still choosing a framework, our comparison of Jekyll, Hugo and Astro covers the trade-offs.

Sveltia is also a Decap CMS alternative, and its config file follows the same format, so if you have used Decap or Netlify CMS before, ours will look familiar.

Step 1: get every piece of text into content collections

Most of the work happened here, before any CMS file existed. A CMS can only edit files. If a heading is typed into an .astro template, no form can reach it.

Before adding Sveltia we moved into content files:

  • The Work page title, eyebrow, intro, and its search title and description.
  • The home page’s section headings and the big hero name.
  • The Studio page title.
  • The contact page’s section heading and the subject line of the email link.
  • The text on the 404 page.

We also cleaned up. Fields left over from an earlier design (color panels and icons) came out of the schemas, and so did a call-to-action file nobody used. Now the schema lists only fields the site reads, and the CMS config can mirror it.

Once that was done, we compared the text of the seven main pages, and their titles and descriptions, with the live site. They were word-for-word the same, so we knew the move had not changed anything visitors could read.

Step 2: add the admin page

Sveltia’s Astro guide says to create public/admin/index.html and public/admin/config.yml. Here is our index.html, minus its one comment line:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noindex">
    <title>Edit Hashk Studio · Sveltia CMS</title>
  </head>
  <body>
    <script src="https://unpkg.com/@sveltia/cms@5/dist/sveltia-cms.js"></script>
  </body>
</html>

Two choices are worth copying. The script URL is pinned to major version 5 (@5), so a future major release will not change the editor under us without notice. And the page carries noindex, so the login screen stays out of search results.

One note from the same Astro guide: the Astro development server does not serve index.html for a folder path in public, so locally you open /admin/index.html rather than /admin/.

Step 3: describe the collections in config.yml

The config starts with the backend, which is a GitHub repository and branch:

backend:
  name: github
  repo: Tortoiz/hashk-studio
  branch: main
  auth_methods: [token]

media_folder: public/images/projects
public_folder: /images/projects

output:
  omit_empty_optional_fields: true
  yaml:
    quote: double

media_folder is where uploaded files are written in the repo, and public_folder is the URL path the site uses for them. The output block keeps the files tidy. Empty optional fields are left out, and strings are double-quoted. Sveltia’s data output docs explain that values it reads from an existing file are written back unchanged unless you edit them, and that data not covered by your configuration is kept. That matters here, because every file existed long before the CMS did.

A files collection for the pages

The six page files are a files collection, one entry per file, so each page appears by name in the editor:

collections:
  - name: pages
    label: Pages
    files:
      - name: work
        label: Work page
        file: src/content/pages/work.md
        preview_path: work/
        fields:
          - *title
          - *seoTitle
          - *description
          - &eyebrow { name: eyebrow, label: Small label above the title, required: false }
          - &headline { name: headline, label: Page title }
          - { name: intro, label: Intro, widget: text }

The &title and *title markers are YAML anchors. We define the search title and description fields once, on the home page, and reuse them on every other page. Change the hint in one place and it changes everywhere.

A folder collection for the projects

Projects are a folder collection over src/content/work. Each project is its own Markdown file, named from its slug field:

  - name: work
    label: Projects
    folder: src/content/work
    extension: md
    format: frontmatter
    create: true
    delete: true
    identifier_field: title
    slug: "{{fields.slug}}"
    preview_path: work/{{fields.slug}}/
    fields:
      - { name: title, label: Project name }
      - { name: slug, label: Address, pattern: ["^[a-z0-9-]+$", "Lower-case letters, numbers and dashes only"] }
      - name: group
        label: Kind of project
        widget: select
        required: false
        options:
          - { label: Websites and platforms, value: web }
          - { label: Mobile apps, value: mobile }
          - { label: Applied AI, value: ai }

The slug: "{{fields.slug}}" line makes the file name follow the Address field instead of the title, so editing a title never renames a file or moves a page. preview_path tells the editor which page on the site to open for that entry. The select widget gives the project kind as a fixed list of web, mobile and ai.

A relation field for the home page

The home page shows a moving strip of projects and a project grid. Rather than typing project names, the editor picks them from the Projects collection:

- name: selectedWork
  label: Moving project strip
  widget: relation
  collection: work
  value_field: slug
  search_fields: [title]
  display_fields: [title]
  multiple: true

The field stores each project’s slug, which is the same value the Astro templates already use to look projects up. The rest of the config is the same set of tools reused: list fields for tools and technologies, markdown body fields for the write-ups, and a hint on most fields so editors know what each one does on the page.

Step 4: check the config before you deploy

A typo in config.yml is easy to make and slow to find by clicking around the editor. Sveltia publishes a JSON schema for its config, and the CMS console points to it. We downloaded the v5 schema from https://unpkg.com/@sveltia/cms@5/schema/sveltia-cms.json and checked our file with a few lines of Node, using the ajv and yaml packages:

import Ajv from 'ajv';
import { parse } from 'yaml';
import { readFileSync } from 'node:fs';

const schema = JSON.parse(readFileSync('sveltia-cms.json', 'utf8'));
const config = parse(readFileSync('public/admin/config.yml', 'utf8'));
const ajv = new Ajv({ allErrors: true, strict: false });
console.log(ajv.validate(schema, config) ? 'VALID' : ajv.errors);

It printed VALID.

Our one real mistake had already shown up in the browser console before that. We had written a hint in flow-style YAML with a comma in it:

- { name: coverAlt, label: Cover description, required: false, hint: What the picture shows, for screen readers. }

YAML read the comma as the end of the value and treated for screen readers. as another key. Sveltia printed a console warning that it was an unknown option. The fix is to quote the hint:

- { name: coverAlt, label: Cover description, required: false, hint: "What the picture shows, for screen readers." }

If you write fields in one-line { ... } style, quote any label or hint that contains a comma or a colon. After validating, open the editor and check the console once.

What else we had to change in the Astro site

Two parts of the site needed changes before the CMS was safe to use.

The sitemap. Our sitemap is built in src/pages/sitemap.xml.ts from the pages collection. Adding work.md and not-found.md to that collection added /not-found/ and a second /work/ to the sitemap, taking it from 28 URLs to 30. We made the sitemap skip the not-found page and dropped the hard-coded /work/ entry. Then we compared the result with the live sitemap: 28 URLs, identical. If anything on your site is built by looping over a collection, check what a new entry adds to it.

The image helper. Our helper expected every cover to exist as three WebP files, at 480, 800 and 1200 pixels, and read image sizes only from WebP headers. A picture uploaded through the CMS is a single file. We changed the helper in src/lib/webp-size.ts so it falls back to the uploaded file at every size, and so it reads PNG and JPEG sizes as well as WebP.

Uploaded images land in public/images/projects, the media_folder from the config.

Signing in and editing the live site

We have no OAuth server, so we sign in with a token. Sveltia’s GitHub backend docs describe signing in with a personal access token without setting up an OAuth app, and the prompt links to GitHub’s token page with the permissions pre-selected.

The first time we loaded the live admin, it showed a Sign In with GitHub button. Without an OAuth server that button would have failed. Setting auth_methods: [token] in the backend removed it, and the sign-in screen now offers one choice.

The Sveltia CMS sign-in screen at hashk.xyz/admin with a single Sign In Using Access Token button
With auth_methods set to token, the live sign-in screen offers only token sign-in.

The editing flow is:

  1. Open hashk.xyz/admin/.
  2. Choose Sign In Using Access Token.
  3. Paste a GitHub fine-grained personal access token limited to the repository, with Contents set to read and write.
  4. Edit in the forms and save.

Each save is a commit to main. Because Cloudflare builds from main on every push, a commit starts a rebuild of the site. The commit_messages block in our config names each commit after the collection and entry, so the Git history reads clearly.

To edit locally, run the Astro dev server and open /admin/index.html in Chrome or Edge, then choose Work with Local Repository. Sveltia’s login screen says the local workflow is not supported in other browsers.

When Sveltia CMS is not the right Astro CMS

A Git-based setup suits a small site with a few editors. It is a poor fit in some cases:

  • Large teams. If you need roles, approval steps or scheduled publishing beyond what Git and your host offer, a hosted CMS built for that will serve you better.
  • Content in a database. Sveltia edits files in a repository. If your content lives in a database or comes from another system, it has nothing to edit.
  • Editors without GitHub accounts. Token sign-in and GitHub’s permissions assume each editor has access to the repository. If that is a problem for the people who will write, you need a different login route or a different tool.
  • Instant changes. A save is a commit, and the site changes only after the next build finishes.

For a portfolio, a studio site or a small business site, those limits usually do not matter.

FAQ

Is Sveltia CMS free?

Yes. It is free and open source under the MIT license.

Does Sveltia CMS work with Astro content collections?

Yes. It edits the Markdown and YAML files that collections read, so you describe each collection in config.yml and point it at the same folder or file. Keep the config fields in line with your zod schema, or the editor and the build will disagree about what a valid entry is.

Do editors need a GitHub account?

With the GitHub backend and token sign-in, yes: the token comes from a GitHub account that has access to the repository. That is how we sign in at hashk.xyz.

Can I use it without Netlify?

Yes. We host on Cloudflare Workers static assets and use the GitHub backend directly. Nothing in our setup involves Netlify.

Where do uploaded images go?

Into the folder set as media_folder in your config, committed to the repository like any other file. Ours is public/images/projects, and public_folder sets the URL path the site uses to reach them.

If you want an Astro site to start from, browse our Astro themes, such as Altair, a one-page portfolio with a blog (here’s how we built it), or Lyra for NGOs and charities. The same setup on a Jekyll site is in our Sveltia CMS on Jekyll post, and the Alcor docs cover its CMS setup.