What are Flat File Content Management Systems?
Content Management Systems supply a collection of tools that nontechnical users can use to manage their content. The CMS has three goals:
- Allow content creation, editing, and deletion
- Allow collaboration
- Allow distribution
It is beneficial for a CMS to allow collaboration between multiple users. The way a CMS distributes the content to users will depend on the CMS type. There are three CMS types, Headless, Decoupled, and Traditional.
Headless Content Management Systems
Headless Content Management Systems focus on the backend of a website. Headless systems focus on supplying an easy solution for content storage and allowing access to the content through an API.
Decoupled Content Management Systems
Decoupled Content Management Systems will have two distinct applications, a frontend, and a backend. The frontend will usually access the content through an API the backend exposes. An example could be a PHP backend and an Angular frontend. This solution allows flexibility in how content is created and distributed, using different applications for different displays.
Traditional Content Management Systems
Traditional Content Management Systems are like their Decoupled sibling, but with the distinction that a single application will manage the content and its distribution.
Popular CMS Choices
A large number of CMSs exist, but these are the most common.
- WordPress
- Drupal
- Joomla
- Magento
- Magnolia
- SharePoint
- Shopify
In the past I had a challenging time working with these systems when wanting to start up a site for some tiny project or idea. What was continually a thorn in my side was working with the database. Although there are systems to try to ease these issues, like a relational system, or GUIs when managing the database. It is interesting how every language ends up with a system for managing the database and trying to make it as simple as possible.
Databases
The most popular CMSs use databases to be able to scale to any solutions size. Databases came at a time when server hardware and code solutions were not as speedy or efficient as they are now. Databases have a suite of tools to help make data gathering as fast and simple as possible.
Databases are a huge hammer that can solve many problems, and there are downsides due to that. Having to know another language, manage another application, and deal with migrations as the application changes.
To get back to a simple state, let us go back to the basics. This new data storage medium does not have indexing, data relationships, triggers, or procedures, and it doesn’t require a server or learning a new language. We are going to go back to a time before many of us. We are going to talk about the foundation of databases. We are going to talk about files, plain text files.
Files all the way down
Yes, files can be a bottleneck, and they do have their downsides, like redundancy for instance. However, files have a good set of attributes that we can use. I know I just said that files can be a bottleneck, but they are by default incredibly performant. Hardware and software have changed a lot, and with that comes faster file access. Files are as secure as the OS and privileges defined in the code. Files are incredibly simple, no need to manage a database just to perform CRUD operations. Does a restaurants website require stored procedures? Probably not. Files are open source and cost effective. Files mean no more migrations! Backing up files becomes a simple Git commit.
Flat File CMS
When you replace a CMSs database with a collection of files, you get a Flat File CMS. Content is a file. A user is a file. Configuration, Cache, Files, are all files.
When considering a flat file CMS, the most refined are Grav, Kirby, and Statamic. I consider these the best options because they have the largest community. When a product has a community, it means there is better support, forums, and documentation.
Most flat file CMSs rely on using a traditional structure, not a decoupled one, to reduce complexity. Most systems also use PHP in the backend and often use a template or plain HTML for the frontend. Using a scripting language for the backend contributes to easy development and easier deployment. PHP and JavaScript are easy to set up on a shared server and that makes hosting simple and inexpensive.
PHP has a poor reputation among developers that work in other languages like Java or C#. It certainly earned that reputation in the past, but improvements since then have made working with PHP much easier. Because of the proliferation of PHP across major hitters like WordPress, there is a large number of existing frameworks and libraries to help with development or supply a supplemental service to your site, like email. The built in HTML templating, simple deployment, and miniscule cost of developing in PHP makes it easy to recommend as a language to use when working with Flat File CMSs.
Standard User Flow
Content
Most flat file CMSs will store content data in a yaml file. The content is organized into fields, with a particular set of characters used to choose when one field ends and the other begins. An example for a blog post
Title: The Start
----
Text: The Posts Content
----
CoverImage: - file://hash
----
Date: 2023-07-24 18:00:00
Templating
After the content is gathered, that data then needs to be injected into HTML in some way. Some systems use a templating system like Twig, others use PHP to inject data into plain HTML. Let us see how that would look using the content yaml from above.
<header>
<h1><?= $page->title()->esc() ?></h1>
</header>
Content Management
Although we could create our content by editing Yaml files, a key part of CMS is the management aspect, and making management of that content easily accessible by the CMSs users. This admin area of the website needs a structure defined to say what fields and relations we want to create for the data. This is, of course, all defined in a file, usually in yaml.
What about the other stuff?
Content, Templating, and Management are the three important things to get done correctly just to have the backbone of a good CMS. The other things, like:
- Plugins
- Templating
- Cache
- Models
- Controllers
- Collections
- Accounts
Are things you should focus on adding in after you have a foundation.
What Can You Do With This
This post is a starter on Flat File CMS, the first chapter in a book. This goal is to get you excited about flat file content management systems and show you the benefits of using them. The thing I like best about these types of CMSs is that they allow you to start simply and add more functionality as you grow.
What you can do with this is anything. Theres a whole suite of applications you can create with flat file CMSs:
- Business Sites
- Blogs
- Tracking Apps
- Custom Ticketing Systems
- Demo Sites
- Storefronts
- Auction Sites
- Membership sites
- Content Distribution
A site that I think any developer could use is a portfolio site, something that allows you to show what you know. Using a flat file CMS will allow you to focus on showing your knowledge instead of managing a second beast of an application, and most importantly avoid databases.