Knowledge Base Theme
Installing the Knowledge Base theme can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the theme with a simple terminal command, while the manual method enables you to do so via a zip file.
The theme by itself is useful, but you may have an easier time getting up and running by installing the skeleton. The Knowledge Base skeleton is a complete site with the theme itself, required plugins and configuration, and sample content.
GPM Installation (Preferred)
The simplest way to install this theme is via the Grav Package Manager (GPM) through your system's Terminal (also called the command line). From the root of your Grav install type:
bin/gpm install knowledge-base
This will install the Knowledge Base theme into your
/user/themes directory within Grav. Its files can be found under
To install this theme, just download the zip version of this repository and unzip it under
/your/site/grav/user/themes. Then, rename the folder to
knowledge-base. You can find these files either on GitHub or via GetGrav.org.
You should now have all the theme files under
NOTE: This theme is a modular component for Grav which requires the CMS itself and the following plugins to properly function as written (you can of course modify the theme once installed):
- Simple Search
- Count Views (for the "Popular Articles" sidebar)
- Reading Time (for displaying the reading time at the top of each article)
- Related Pages (for the "Related Articles" section at the bottom of each article)
Backwards Compatibility Alert: If you are updating from 1.x and have used theme inheritance to customize the theme, then you must copy the contents of your customized
knowledge-base.yaml file into your new theme's configuration file.
Furthermore, if you have overridden any template files, please note the following change. All instances of
config.themes['knowledge-base'] have been replaced with
As development for the Knowledge Base theme continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience. Updating Knowledge Base is easy, and can be done through Grav's GPM system or manually.
GPM Update (Preferred)
The simplest way to update this theme is via the Grav Package Manager (GPM). You can do this with this by navigating to the root directory of your Grav install using your system's terminal (also called command line) and typing the following:
bin/gpm update knowledge-base
This command will check your Grav install to see if your Knowledge Base theme is due for an update. If a newer release is found, you will be asked whether or not you wish to update. To continue, type
y and hit enter. The theme will automatically update and clear Grav's cache.
Manually updating Knowledge Base is pretty simple. Here is what you will need to do to get this done:
- Delete the
- Download the new version of the Knowledge Base theme from either GitHub or GetGrav.org.
- Unzip the zip file in
your/site/user/themesand rename the resulting folder to
- Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing
Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in
user/config/themes) will remain intact.
To modify or customize this theme, you must first read and follow the documentation on theme inheritance. Following these instructions is the only way to ensure that your changes are not lost when the theme gets updated.
NOTE: You will need to copy and paste the contents of
knowledge-base.yaml into your newly created
This theme can be configured in two places:
Here is the default configuration, which is commented to explain what the different settings do:
params: articles: root: /home # the route where the articles themselves live blacklist: ['scratch'] # list of categories to ignore show: # if all are set to false, the article header is removed date: true # show article date in the article header authors: true # show article authors in the article header topics: true # show assigned topics in the article header time: true # show reading time in the article header front: # params for the front page content maxrows: 3 # the maximum number of rows on the front page maxentries: 5 # maximum number of articles displayed for each category sidebar: # params for the sidebar maxentries: 5 # maximum number of articles to display in "Popular" and "Latest" sections show: # if all are set to false, the sidebar is removed categories: true # show Category list in the sidebar popular: true # show the Popular Articles sidebar latest: true # show the Latest Articles sidebar
params:articles:blacklist: Any articles containing a blacklisted category will not appear on the front page, in the sidebar, or in the list of articles by a given author.
site.yaml must specify three taxonomies:
The only theme-specific customization looked for here is the text for the footer. You can change the footer text without touching the templates by adding something like the following to
footertext: | <p> First footer line. </p> <p> Here's a second. </p>
The template loads
theme://css/custom.css if it exists. The simplest way to customize the CSS is to create this file in your inherited theme and add what styles you need. This way the base
css/knowledge-base.css can be updated without losing your customizations.
To override templates, simply copy the file from the base theme into the same place in your inherited theme and edit as desired. If you configured your inheritied theme correctly, the Grav system will first look for files in your inherited theme. If it's not present, it will pull the file from the base theme.
The following templates are available:
authoris used for displaying information about an author and articles they have authored.
defaultis a blank template that just dumps a page's content.
erroris used for displaying error messages.
frontis only used for generating the front page. The front page is organzed by the
itemis used for an article.
taxonomyis used to display articles by taxonomy (i.e., category, tag, author).
Hopefully you're working with the skeleton packge that contains all the sample content. If not, at least have a look at that repository so you can follow along.
The theme expects three routes under the
/home(or whatever was specified in
This is where all the knowlege base articles live. Each article should have its own folder containing an
item.mdfile. There are a few prerequisites for the page front matter:
- It must contain a
- It must contain an explicit
datefield representing the published date.
- It must have at least one
categoryassigned for it to appear on the front page.
tagis completely optional.
authoris recommended. Multiple values are supported in any taxonomy.
Two different icons are currently supported. By default, all articles are marked with a "text" icon. If the article contains media (usually video), then add
media: videoto the front matter. The "video" icon should then be used.
- It must contain a
This is where users can get lists of articles by taxonomy. The
taxonomy.mdfile can be titled in any way you wish, and it is recommended that caching be disabled. If no query parameters are passed, then it will display a list of known taxonomies. If a taxonomy is passed via the
nameparameter, then it will list valid values for that taxonomy. If the taxonomy value is also passed (via the
valparameter), then a list of all articles matching that specific taxonomy will be listed.
A note about authors: If a specific author page exists (see
/authorsroute below), then the author's name will link to it. If no such page exists, then a generic list of articles will be generated.
This folder should contain a top-level page that contains the following front matter:
All other content and headers will be ignored.
The folder should then contain folders for each author (optional). The slug is determined by the built-in
hyphenizetwig filter. Each of those folders should contain an
author.mdfile. The page's front matter must include an
authorfield containing the properly capitalized and spaced name of the author. The template will create an initial heading, dump the page content (including images), and then follow with a list of articles this person authored. If no such folder exists, then the
/taxonomypage will create a simple list of articles written by that author.
The sample content also shows a "Contact Us" page that you will need to configure yourself.
This is my first theme. Feedback and pull requests are warmly welcomed.
I decided to try this after a forum post asking if such a template already existed. The poster linked to a theme called "knowhow" by Hero Themes. That theme inspired this one, but this one was coded completely from scratch with no reference to the original code.