I recently setup my own blog using a ‘flat-file’ content management system known as GRAV. If you are unaware of what a Flat File CMS is, it’s essentially a CMS like WordPress in where it uses PHP to process logic. Where it’s different is in it’s lack of database, for storing posts and other data it uses flat text files. It’s pretty neat. In the short time since my install, I’ve installed five amazing small plug-ins, and have built out my own custom theme using CSS and TWIG. It’s been a fun experience working with the small CMS, I’ve especially enjoyed having a full blog at roughly 30mb in size. It’s incredibly fast. So in this post I’m going to be giving a small introduction to the CMS.
We’re going to head on over to Grav’s download page and grab the ‘Grav Core + Admin Plugin’ bundle. Once you’ve downloaded and extracted the zip, you’ll find the entire CMS plus the admin plugin in that 20mb folder.
What’s in the box?
I’ve attached a screenshot of an almost default folder structure below with the only modification being the addition of the .ddev folder.
Almost everything you need is located under the user folder. That’s the really neat thing about this CMS. Rather than storing your posts in a database like a traditional CMS such as WordPress or Drupal, GRAV stores them right in your users/pages directory. The pages are then organized into folders that contain their respective markdown files.
Themes could, and probably should, get it’s own post. There’s so much to go over when it comes to themes, and it’s all really cool. I’m going to keep it brief for this post. Themes in GRAV are made using TWIG, a PHP template engine. For my own custom theme, I downloaded a blank starter theme, and started with two template files, a ‘blog.html.twig’ for my blog posts and a ‘default.html.twig’ for any non-blog pages. In these TWIG files, there are PHP code that pull in my template partials, such as my footer, header, etc. from my partials folder and pieces them all together. I’ve attached a screenshot of the folder structure for the default theme, Quark to give a clearer image.
Setting up a local
In order to setup and start developing locally, we gotta do some prep work first. We need to install Docker and DDEV. Docker is a straight forward install, create an account, download the DMG, slide the Docker.app into your applications folder. For DDEV, I chose to install it via BREW. Assuming you have BREW installed, we must first add the ddev repository using
brew tap drud/ddev once it’s added, we can run the following to install ddev onto our machine.
brew install ddev
We should at this point have DDEV and Docker installed, so now we’re ready to get started. Let’s move our Grav folder from downloads to a more secure location. I moved mine into my “Sites” folder in my home directory. Open Terminal and lets CD into our site folder.
Once there, we want to run
ddev config we will then be prompted to enter a name for our project. I chose grav-demo in this case.
Another prompt appears asking us the DocRoot location, leave it blank. Finally, the last prompt will ask us to enter the project type, in our case it is PHP.
And now we run
This may take a bit since it’s building out our container. Once it’s done it should spit out a nice link where we can view our local install.
The first screen you’ll be presented with is the Admin User Creation screen, since we have the admin plug-in installed by default but no admin accounts. Create one and it’ll throw you right into the admin panel.
Here we have a brief overview of our site’s backup and update status, and the visitor count. In the sidebar, we can see quick links to our site configuration, pages, plug-ins, themes, etc.
If we head into pages we can see the default pages that come with GRAV, HOME and TYPOGRAPHY. Here in this section, we can add folders and pages to our site and organize them however we like.
If we click on a page, we will be able to edit it via a WYSIWYG. By default it will look like the following, but you can install other more advanced editors if you so choose.
Straight forward, installed plug-ins will show up here. You can even search for new plug-ins to install right in this section via the +add button which is super convenient.
Themes you create or install will show up in this section and can be activated/deactivated, here.
So there you have it, in a brief, 5 minute read – that was an intro to the tiny GRAV CMS. A small flat file CMS that can really do a lot! For me, experimenting with GRAV got me interested in other small content management systems such as WonderCMS and OctoberCMS. So far I’ve played around with WonderCMS, but am very curious to try out October for its Laravel framework. For now, I’ll stick to working on my current GRAV install and experiment with the theming.