Abandonment Notice: I'm afraid I simply don't have the time to maintain my Grav themes and plugins. Those interested in taking over should refer to the "Abandoned Resource Protocol". Feel free to fork and replace. So long, and thanks for all the fish.
The Header By Taxonomy Plugin is for Grav CMS. The plugin allows you to inject headers into pages based on their taxonomy
Installing the Header by Taxonomy plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.
The simplest way to install this plugin 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 header-by-taxonomy
This will install the Header by Taxonomy plugin into your /user/plugins
directory within Grav. Its files can be found under /your/site/grav/user/plugins/header-by-taxonomy
.
To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins
. Then, rename the folder to header-by-taxonomy
. You can find these files either on GitHub or via GetGrav.org.
You should now have all the plugin files under
/your/site/grav/user/plugins/header-by-taxonomy
NOTE: This plugin is a modular component for Grav which requires Grav, the Error and Problems plugins, and a theme to be installed in order to operate.
All you need to do is configure the plugin as described below. Everything else is automatic. Possible uses include the following:
-
Activate a plugin (for plugins that allow page-by-page activation, like
pubmed
) -
Inject specific meta tags via the
metadata
header -
Inject twig variables
The plugin comes with a sample configuration file. To change it, copy header-by-taxonomy.yaml
to your user/config/plugins
folder and edit as you see fit.
enabled: true
overwrite: false
sets:
- criteria:
- taxonomy: category
values: [Food]
combinator: or
- taxonomy: tag
values: [Indian]
combinator: or
combinator: and
overwrite: true
header:
metadata.refresh: 300
metadata.key2: value2
pubmed.active: true
test.var: "Hi!"
-
The
enabled
field allows you to turn the plugin off and on. -
The
overwrite
field tells the plugin what to do overall if a header already exists in the page file itself. The default isfalse
. -
The
sets
field is where all the action happens. The plugin processes each set in sequence.-
The
criteria
field is how the plugin determines whether the given page should be processed. It is an array of one or more conditions that must evaluate totrue
for the header to be modified.-
taxonomy
is the name of the taxonomy you wish to examine. -
values
lists the one or more values you're looking for in that taxonomy. -
combinator
tells the plugin how to assess the givenvalues
. The only options areor
andand
. Anything else (including if it is simply omitted) is interpreted asor
.
-
-
The overall
combinator
field is only useful if you have more than onecriteria
. It determines how the results of the individualcriteria
should be assessed. The only options areor
andand
. Anything else (including if it is simply omitted) is interpreted asor
. -
This optional
overwrite
field can be used to override the globaloverwrite
field for a specific set. -
The
header
field is where you put the key-value pairs you wish to insert into the page. Use periods (.
) to separate nested values.
-
The results are cached, so the hit should be minimal.