Skip to content
Sveltia CMS
Esc
↑↓navigate↵open⌘Jpreview
On this page

Configuration Editor

Edit the Sveltia CMS configuration file from within the CMS, including global options, collections, fields and backend options, with validation before saving.

The Configuration Editor lets you change the CMS configuration file without leaving the CMS. You can edit the global options, add and arrange collections and singletons, build their fields, and save the result back to your repository.

It’s meant for developers setting up a site. With a Git backend, it only appears in Developer Mode, so content editors don’t come across it.

Opening the Editor

Select Administration in the toolbar, then CMS Configuration in the sidebar. The section is available:

In both cases, the Administration page appears in the toolbar, with or without Sveltia CMS Additions.

Requirements

The configuration can be edited when it comes from a single YAML, TOML or JSON file in the repository. The section only shows the configuration the CMS has loaded, and says why, if:

A YAML file that uses aliases, including merge keys, can’t be edited either, because the aliases couldn’t be kept when the file is written back. Edit such a file in a text editor.

Finding the File

The CMS knows the URL its configuration is served from, e.g. /admin/config.yml, but not where that file lives in your repository. The editor looks for it in the common static folders, such as public, static and docs/public, and picks the one whose content matches what the site serves.

If the file isn’t found, enter its path relative to the project’s root folder, e.g. site/static/admin/config.yml, and select Open. The path is remembered once you save the file.

If the file in the repository differs from the configuration the site serves, the editor tells you so and asks you to confirm before editing. With a Git backend, this usually means a change hasn’t been deployed yet. Locally, make sure you’ve opened the right file, not a copy in your build output.

Editing the Configuration

The editor has three tabs:

  • Global Settings: the top-level options, such as site_url, media_folder and app_title. Options holding options of their own, like i18n, slug and editor, can be expanded to edit those.
  • Collections: the collections and singletons. See below.
  • Backend: the backend options. See Backend Options.

Each option is labeled with its name in the configuration, and has an input that matches its type:

  • A text or number input for text and numbers.
  • A list to choose from for booleans and options with a fixed set of values. Default leaves the option out, so its default applies.
  • A multi-line input for a list of strings, one value per line, e.g. the options of a Select field.
  • A list with more choices for an option that takes more than one kind of value:
    • Custom shows a set of options to fill in, e.g. for the i18n option of a collection.
    • Text shows a text input, e.g. for a template in the slug option of a collection.
    • List shows a multi-line input, e.g. for the locales in which a field is required.

Options the editor can’t show, such as lists of objects, are kept as they are. Edit them in the file.

Collections and Singletons

Select Add to add an entry collection, a file collection, a singleton or a divider. Except for a divider, you’re asked for a name, a label and the folder or file the content is stored in. A new collection or singleton starts with a Title field.

Drag an item to move it within its list, or use the arrow buttons to move the selected item up or down. The trash button deletes the selected item. Deleting a collection only removes it from the configuration: its content files stay in the repository.

The selected item’s options are in two tabs:

  • Settings: the collection or singleton options.
  • Fields: the fields, as a tree. For a file collection, the tab is called Files and lists the files, each with its own settings and fields.

Fields

The field tree shows each field with its type. Subfields of List and Object fields, and their variable types, are shown under them.

  • Add Field adds a field next to the selected one, or at the top level if none is selected.
  • Add Subfield adds a subfield to the selected List or Object field. For a field with variable types, it reads Add Variable Type.
  • Drag a field to move it within its list, or use the arrow buttons to move the selected field up or down. A field can’t be dragged into another field.
  • The trash button deletes the selected field. Values already entered in it stay in the content files.

Select a field to edit its options. Changing its Field Type removes the options the new type doesn’t take and adds those it requires, which you then fill in. Subfields are kept when the new type can have them.

Backend Options

The backend options tell the CMS which repository to use and how to sign in. A mistake there can keep everyone from signing in, or send their sign-in to another site. That’s why the options only appear once you select Edit Backend Options and confirm. The name and private_config options can’t be changed here.

With a Git backend, a saved configuration with changed backend options isn’t used until the site serves it, and neither are the other changes saved with it. See Applying the Changes.

Saving

Select Save to write the file. The configuration is checked the same way the CMS checks it when loading, and isn’t saved while it has errors, which are listed above the tabs.

The file is written in its original format, keeping its style where the editor can tell: the indentation of a JSON file, how the lists of a YAML file are indented, and the line breaks. The top-level options stay in their order, new ones are added after them, and singletons and collections, usually the longest, always come last.

YAML and TOML files are written out anew, so their comments are lost. The editor asks before saving a file that has any. A $schema comment on the first line is kept.

With a Git backend, the change is committed with the message “Update CMS configuration”. The commit always triggers a deployment, even when skip_ci is enabled. With a local repository, the file is saved to your project folder, and committed if you’ve turned on Git commits.

Select Discard to throw away your changes.

Unsaved Changes

Your changes are kept while you visit other parts of the CMS, and restored when you come back to the section, unless the file has changed in the meantime. They’re only kept until the page is reloaded or closed, and the browser asks before you reload or close a page with unsaved changes.

Applying the Changes

Once the file is saved, the CMS reloads and uses the new configuration:

  • Local repository: your development server usually serves the file you’ve just saved, so the CMS uses it right away. If the browser asks, select the project folder again.
  • Git backends: the site keeps serving the old file until your change is deployed. In the meantime, the CMS uses the saved configuration in your browser only, and a notice says so.

With a Git backend, the browser stops using the saved configuration:

  • once the site serves the new file
  • if the file is changed some other way in the meantime
  • after 24 hours

A saved configuration that changes the backend options isn’t used until it’s deployed, so nothing kept in the browser can point the CMS at another repository or sign-in server. A notice tells you that the changes are waiting.