Skip to content
A plugin for generating SEO meta tags
PHP Hack
Branch: master
Clone or download

Latest commit

Latest commit 898659c Apr 6, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
blueprints Better Label Mar 14, 2020
snippets FB Locale Added Apr 6, 2020
.gitignore First Edition Feb 8, 2020
README.md Readme Fix Mar 14, 2020
composer.json First Edition Feb 8, 2020
index.php FB Locale Added Apr 6, 2020

README.md

Kirby 3 SEO Plugin

A small plugin for generating meta data using shared controllers and field data. Also creates Facebook Opengraph and Twitter social sharing information.

Installation

Manual

To use this plugin, place all the files in site/plugins/kirby3-seo.

Composer

composer require hashandsalt/kirby3-seo

Commerical Usage

This plugin is free but if you use it in a commercial project please consider to


Usage

After installing the plugin, setup controllers to bring in the shared SEO controller into each of your template controllers.

The bare minimum controller looks like this:

<?php

return function ($page, $kirby, $site) {

  // SEO
  $seo = $kirby->controller('seo' , compact('page', 'site', 'kirby'));

  return $seo;

};

To override any of the values, you can do this inside your controller. For example, to change the format of the meta title, you could do this:

<?php

return function ($page, $kirby, $site) {

  // Meta
  $seo = $kirby->controller('seo' , compact('page', 'site', 'kirby'));

  // Override Meta Title
  $metatitle = $page->seotitle().' | '.$site->title();

  $data = compact('metatitle');

  return a::merge($seo, $data);

};

Additionally, you need to populate the pages with information that is needed for the meta tags to be filled out correctly. The plugin contains blueprints for this and are meant to be used as tabs in your pages:

title:     Default

tabs:

  # SEO META
  meta: tabs/seo/meta

In the site.yml also setup the contact tab which will capture social media account information.

title:     Site

tabs:

  # Contact
  contact: tabs/seo/contact

Finally, output the meta tags in your templates with the following snippet.

<?= snippet('seo/meta') ?>

For convenience the plugin also contains a favicon snippet:

<?= snippet('seo/favicon') ?>

You can generate the favicons at this website link

Generating JSON Schema data

To generate any kind of schema data, you can use our Schema plugin in tandem with this plugin.

You can’t perform that action at this time.