hashandsalt / kirby3-seo
Kirby 3 - SEO tools
Installs: 3 719
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 3
Forks: 2
Open Issues: 1
Type:kirby-plugin
Requires
README
A small plugin for generating meta data using shared controllers and field data. Also creates Facebook Opengraph and Twitter social sharing information.
Using Kirby 4? a version of the plugin is available here - kirby4-seo
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.