Managing content
Files and folders are Kirby's primary data source in which you can organize your content exactly how you need it. If you need to build to scale, you can go beyond and add data from any data source.
The content folder
The heart and soul of your Kirby installation: Let's learn how to create pages and add content with simple text files and folders.
Files and folders
Since Kirby is a flat-file CMS, all content is stored in files and folders within the content
folder. Each folder you create represents a page that is accessible via its own URL.
If you create a folder called blog
as direct child of the content
folder, it will be accessible via https://yourdomain.com/blog
etc.
Page folders can serve as pages in their own right, i.e. only contain the content from their own folder, or they can serve as data containers for their parents, or they can be used in other parts of the project.
All content you create in the backend can also just serve as a data store, ready to be consumed in your SPA or other types of media.
Content in Kirby can also come from a database, from an external API, Excel sheets or any other data source. We will cover this in other parts of the documentation.
Editing content
The flat-file architecture of Kirby makes creating and editing content in Kirby highly flexible. You can create content in three ways in Kirby, in fact, all three ways can be used in parallel.
-
You can use the Panel to edit content and upload files.
-
You can create files and folders manually in the file system and edit content files with the text editor of your choice.
-
You can create and modify content programmatically using Kirby's API, for example, create pages from
.csv
files or from form content on the front-end.
Publishing workflow
Customizable page states give you maximum control over your workflow, from drafts over unreviewed to published pages. Choose what you need and start creating.
In Kirby, pages can have three states:
- draft
- listed
- unlisted
Drafts are only accessible to logged-in users, while listed and unlisted pages are accessible via their URL.
You can use these states to filter files in the frontend or to implement a multi-step publishing workflow for drafts, in-review and published pages.
Structuring content
Your content is your biggest asset, and structuring it in a way that makes it easily accessible and ideally reusable across different types of media (Single Source Publishing) is therefore important.
Organize content your way. Every page type or data entry can have the completely unique data structure that your project demands.
Use nested hierarchies to your advantage
Another aspect of the content structure is the hierarchy. Hierarchies are naturally created from the URL structure of your site. Every nested URL corresponds to a nested folder structure in your content
folder.
Sometimes you will have pages with a lot of children, e.g. blog posts, events, product variants etc. To increase the overview and also Kirby's performance, it may make sense to add an extra nesting layer to such hierarchies. Let's take a blog as an example:
- blog.txt
1_through-the-desert
- post.txt
2_chasing-waterfalls
- post.txt
3_a-night-in-the-forest
- post.txt
- ...
If you can already foresee that this blog will have several hundreds or thousands of subpages, you can help Kirby to keep your site fast by reducing the size of each subtree. Here we'll add a nesting layer with the publish year of the blog post:
- blog.txt
2023
1_through-the-desert
- post.txt
2_chasing-waterfalls
- post.txt
2024
1_a-night-in-the-forest
- post.txt
- ...
This allows Kirby to traverse the page tree more quickly as it doesn't have to read every single directory even for requests that only need to access one or a few pages. However, note that premature optimization isn't great either. If you don't expect hundreds or thousands of subpages, there is no need to do this.
Media files
Kirby stores media files in the same folder as the page content instead of putting everything into a huge media library. In addition, you can store media files in the site
object, i.e. directly in the content
folder.
Kirby works with all types of media files and allows you to store meta data for each file in the same flexible way you can store information for pages.
Text formatting
When writing for the web, nobody really wants to wrap HTML tags around text. On the other hand, most WYSIWYG editors produce awful HTML output and have tons of other issues. In Kirby, content is therefore marked up and formatted in Markdown or our extended version of it, which we call KirbyText.