Collections and files
content is a list. Each item is one of three types:
collection: a folder of files that share fields, such as blog posts.file: one file with its own fields, such as site settings.group: a sidebar section containing other items.
Collections
Add a collection to .pages.yml to edit the files in a folder:
content:
- name: posts
label: Posts
type: collection
path: src/content/posts
fields:
- name: title
type: string
- name: body
type: rich-textEvery file in path with the collection's extension is an entry. The extension comes from the filename template, .md by default. New entries are created in the folder and named by that template.
If a folder with many entries times out while loading, set large: true on the collection. SP CMS then reads the folder at one commit and loads its files in batches. The first load can take longer; later refreshes reuse cached text for unchanged files. Sorting, search and pagination still work across the whole collection.
Files
Add a file to .pages.yml to edit it on its own:
content:
- name: settings
label: Site settings
type: file
path: src/data/settings.yml
fields:
- name: title
type: string
- name: description
type: textpath is the full path to the file, including its name. If the file is a top-level list, such as an array of authors, set list: true. An object such as list: { min: 1, max: 20 } also limits the number of items.
- name: authors
type: file
path: src/data/authors.json
list: true
fields:
- name: name
type: string
- name: avatar
type: imageWithout fields, a file opens in a source editor. See file formats.
Groups
Groups organise the sidebar. They don't change where content is stored, and they can be nested. A group takes name, label, type: group and items, but no icon.
content:
- name: blog
label: Blog
type: group
items:
- name: posts
type: collection
path: src/content/posts
fields: [{ name: title, type: string }]
- name: authors
type: collection
path: src/content/authors
fields: [{ name: name, type: string }]Keys
Operations
By default editors can create, rename and delete collection entries, and create or delete a single file. Set an operation to false to turn it off:
- name: legal
type: collection
path: src/content/legal
operations:
create: false
delete: falseSet operations: false to turn off every operation. Editors can still edit existing content.
Operations apply to everyone, managers included, and SP CMS enforces them when saving as well as in the interface. They only take actions away; they don't grant access.
Sidebar icons
icon takes a name from the Hugeicons free set in PascalCase, with or without the Icon suffix, such as News01 or News01Icon. Unknown names fall back to the default icon. Media libraries also accept an icon.