In this video we’re going to take a look at why you might want to look at Grav CMS.
As you may know, prior to making YouTube videos, I was a website developer. I worked for a couple of different agencies and even had my own business for a while that I eventually sold to another company and then took over their development as part of the deal.
Some Background
During my dev years, I focused primarily on front-end development, but used a few different methods of building.
The simplest was building static sites from scratch (or with a framework), while other times I used different content management systems ranging from Joomla to Magento to WordPress and a few others as needed.
Because of this I’ve always been interested in how different content management systems worked and the requirements for developing themes and plugins for each of them.
I spent the majority of my time and efforts on WordPress, so that’s where most of my experience comes from.
I’ve been hearing about another system called Grav CMS for a while but finally decided to give it a look.
What We’re Doing
Just as a note: There are multiple ways of deployting Grav. You might download their install package, do a one-click install on a managed hosting provider, or, in our case, use a Docker solution to deploy Grav.
Specifically in this video we’re going to use LinuxServer’s Grav container. I’ve been using LinuxServer images for years now and have never had any issues with their setups.
About Grav
So why would you want to use Grav? The simple answer is that Grav doesn’t use a database. Grav uses a flat-file configuration instead that generated a folder and file structure similar to what you may have seen back before content management systems were even a thing and each page had to be hand-coded.
Why is this important? Because this means that there are no database queries when someone visits a page or post on your site. No database queries theoretically means faster response times to load a page.
Also, not having a single point of entry, like a database, makes it harder for a bad guy to run a single query on your server to take over an entire site. I speak from personal experience and can attest to why regular backups are SO important.
Despite Grav being a flat-file CMS, they’ve done something interesting and have still managed to incorporate adding additional functionality via plugins like you might see in a system running on a database like WordPress or Drupal.
Grav themes are done with Twig Templating. Markdown is used for content/data entry. Yaml files are used for configuration. There is a ton more information about Grav over on the website and GitHub repository.
I’ll have links in the description if you want to check that out.
So, with that somewhat lengthy intro out of the way, let’s take a look at how easy it is to get Grav CMS installed via Docker and even set up on a domain using Cloudflare Tunnels.
To get started, you’re going to need a Docker server set up and ready to go. You can use command line or Portainer to deploy Grav as the LinuxServer team has created a CLI command and a docker-comose to deploy the Grav container.
If we take a look at their hub.docker.com page, we can see things like the supported architectures as well as the the different ways to deploy their container.
We’re going to use the docker-compose method just for simplicity. Whether you want to use command-line or Portainer is completely up to you.
Be sure to copy the docker-compose from the hub.docker.com page and paste it into your desired way to deploy.
Deploy via CLI
To do it in CLI, you’d want to SSH into your server and create a file called docker-compose.yml.
Paste the docker-compose information from the hub.docker.com page into the file you create and be sure to edit things like the Time Zone and the path where you’d like to install it on your server.
You can change the port that you’ll use to access Grav, but be sure to only change the first 80 on the port line and don’t change the colon or anything after it.
Once you’re done with that, you can save and exit the file and then bring up the container by running
docker-compose up -d.
If you get an error that docker-compose can’t be found, you can run
docker compose up -d
After a few moments, the container should come up and you should be able to access the install via the IP address and port for your server and you should be asked to create an admin account.
Deploy via Portainer
To deploy Grav using Portainer, you can login to your Portainer instance and create a new stack. Once you’ve clicked on the “Create New Stack” you can give the stack a name. I would probably go with “grav” but make sure to use all lower-case letters or Portainer will have a fit.
Paste the docker-compose information from the hub.docker.com page into the file you create and be sure to edit things like the Time Zone and the path where you’d like to install it on your server.
You can change the port that you’ll use to access Grav, but be sure to only change the first 80 on the port line and don’t change the colon or anything after it.
Once you’re happy with your stack’s configuration, you can brin up the container by clicking the “Deploy Container” button.
After a few moments, the container should come up and you should be able to access the install via the IP address and port for your server and you should be asked to create an admin account.Creating Admin Account
To create an admin account, you can just fill in the details on the page for things like username, password, email, etc.
Once you’ve entered everything you can click the “Create User” button and you’ll be logged into the admin dashboard.
The Admin Dashboard
One of the things I like about the dashboard is the “Maintenance” block showing if ther eare updates and when the last backup was run. It also allows you to run a backup from right there.
You can also see Page view statistics, notifications, and a news feed for information related to Grav CMS.
At the bottom you can see the pages that were most recently updated pages.
The left side bar
We’ll nagivate around the admin area of the site via the navigation bar on the left side of the page.
In that menu we’ll find Configuration, Accounts, Pages, Plugins, Themes, Tools, and a Logout link.
The one thing we won’t find in the left side bar is how to configure email, so let’s take a look at that before we go too much farther.
Configuring Email
If you’re using command line to administer your site, you can SSH into your server and then run this command to get into your Docker container’s:
docker exec -it grav bash
Then, navigate to
/config/www/user/plugins/email
and edit the email.yaml file using nano or your favorite editor.
You’ll want to edit the from, from_name, to, and too_name to reflect your setup.
Below that you’ll see a section heading called “mailer”.
By default Grav CMS is configured to use sendmail to handle sending emails for password resets and that sort of thing. You’ll probably want to change it to SMTP so that it looks more like this, but I’ll have a link in the description with more information and options for different ways to send email from your Grav setup.
Something I noticed, is that I wasn’t able to reset my admin password via this method.
Manually Change Password
To change your password manually, you’ll want to login to your docker container via either CLI or Portainer. Then you’ll navigate to /config/www/user/accounts
And then edit the file with the username you want to change the password for.
Then go to the line with “hashed_password” and delete it.
On the new empty line, you can then create a new line that looks like this:
password: yournewpassword
Then go back to your Grav CMS instance and login using the password you just entered. Doing this should log you in but should also encrypt the password you just entered via plain text.
With that said, let’s go back to the left menu of the admin area.
The left side bar Continued
Near the top of the left side bar, we’ll see a couple of icons. The first icon will clear the site cache which is a helpful way to start your troubleshooting if you’re building a site and not seeing the changes you just made.
The plus sign will take you over to the plugins install page just as a quick link.
Configuration
The Configuration link will letyou do things like set the home page, default theme, time zone, timeout, SSL, Session domain and path, and SO much more. I could probably make an entire video about just the configuration tab.
I encourage you to dig around and see what you find. If you’re not sure what something is or what it does, Grav has a ton of documentation on their site. Again, I’ll have htis lined in the description.
Accounts
The accounts section is where you’ll create the accounts for the site and set the permissions of each account. This includes the ability to change the passwords for your users.
Pages
This is where you’ll create pages and posts on your site. This also includes how you’ll configure your page and post structure on the site.
When we get into building our pages and posts, something to consider is tha themes will change some of the available settings in the “advanced” tab. Different themes will have different page templates available and those will be shown here as well. Different page themes will include different styling, layout, and more.
Plugins
The site has a few plugins installed by default to extend the functionality of the site. On the Plugins page you’ll be able to enable, disable and administer the plugins installed on the site.
Near the top of the page there’s a link to check for updates as well as an “Add” button. Clicking the “add” button will allow you to quickly look through the repository of available plugins and quickly add them to your site with just a few clicks.
While most of the plugins on this page are free, there are a few that are commercial and will have a fee associated with them.
Themes
Themes are, in simple terms, the look and feel of your website. It’s the foundation of what viewers of your site will see.
As I mentioned earlier, some themes will add additional page/post types for your content, but might also add additional configuration options in the admin area of your site.
To go along with that, Plugins may also add more links to your admin panel for additional administrative functionality.
Tools
The tools section will allow you to managed your backups, scheduled tasks, view logs and reports, as well as install Grav packages.
Conclusion
After spending a bit of time with Grav CMS, I have to say that it’s quite a bit more rebust out of the box than other CMSes I’ve tried in the past and I think I’d like to spend more time with it to get even more familiar.
Let me know in the comments section below if you’ve used Grav or if you’d consider using it now that you’ve seen this video. What do you like about Grav? Or what DON’T you like about it? Let me know in the comments down below.