Grav Metadata Extended Plugin

Metadata Extended is a Grav plugin and enhanced the metadata feature inside Grav.

Installation

Installing the plugin can be done in one of two ways. Our 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.

GPM Installation (Preferred)

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 metadata_extended

This will install the Simple Form plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/metadata_extended.

Manual Installation

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 metadata_extended. You can find these files either on GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/metadata_extended

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.

Usage

The plugin comes with some sensible default configuration, that are pretty self explanatory:

Options

Enables or Disables the entire plugin for all pages (default: true).

enabled: (true|false)

Fields array.

fields:
  og:
    title: "{% if page.title %}{{ page.title | e('html_attr') }} - {% endif %}{{ site.title | e('html_attr') }}"
    description: "{% if page.summary %}{{ page.summary | striptags | e('html_attr') }}{% else %}{{ site.metadata.description | e('html_attr') }}{% endif %}"
    type: "page"
    url: "{{ page.url(true) }}"
    image: "{% if page.media.images is iterable %}{% set image = page.media.images | first %}{{ image.url }}{% endif %}"
    updated_time: "{{ page.modified }}"

To customize the plugin, you first need to create an override config. To do so, create the folder user/config/plugins (if it doesn't exist already) and copy the metadata_extended.yaml config file in there and then make your edits.

Another nice feature is the generate metadata tags into your theme, for this you need to use the Twig Function {{ generate_metadata() }} or include/override the main template file located in user/plugins/metadata_extended/templates/plugins/metadata_extended/metadata.html.twig with this Twig code:

{% include 'plugins/metadata_extended/metadata.html.twig' with { meta: page.meta } %}

You can customize the design of form override the files in user/plugins/metadata_extended/templates/plugins/metadata_extended/ to user/themes/your-theme/templates/plugins/metadata_extended/ but is useless because is a standard HTML code.

With the v1.0.1 we added another nice Twig function for HTML title tag {{ generate_title() }}, is the same in Twig template:

{% if page.header.title and (page.url != base_url or 'error' == page.template) %}{{ page.header.title }} | {% endif %}{{ site.title }}

Updating

As development for this plugin 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 this plugin is easy, and can be done through Grav's GPM system, as well as manually.

GPM Update (Preferred)

The simplest way to update this plugin 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 metadata_extended

This command will check your Grav install to see if your plugin 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 plugin will automatically update and clear Grav's cache.

Manual Update

Manually updating this plugin is pretty simple. Here is what you will need to do to get this done:

  • Delete the your/site/user/plugins/metadata_extended directory.
  • Download the new version of this plugin from either GetGrav.org.
  • Unzip the zip file in your/site/user/plugins and rename the resulting folder to metadata_extended.
  • Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing bin/grav clear-cache.

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/plugins) will remain intact.