How to setup kirby3 seo plugin in details

Hi everyone, I need help on how to setup SEO plugin in kirby3, I have never used SEO on any of the kirby website i developed, This is my first time and It’s over 2 days since I have been trying to figure it out.

  1. Page doesn’t load when seo snippet is placed in the template.
  2. How to manage it using panel.

I need help please

Which plugin? Please post your code!

<?php return function ($page, $kirby, $site) { // SEO $seo = $kirby->controller('seo' , compact('page', 'site', 'kirby')); return $seo; };

Have you followed the instruction from the readme?

@jimbobrjames That’s probably your plugin?

yes, i do not understand the readme because I followed everything in there, but it gives error and the page fails to load.

@texnixe Yup its mine :slight_smile:

@John2202 At the very least, you need to create a controller for each page template, and drop the following into it:

<?php

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

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

  return $seo;

};

Then snippet will work (you should put the snippet inside the head tag). If you can give me more detail about the error you are getting, I will do my best to help you.

For inner pages, you probably want to customise things like the page title. You can do that by overiding the variables in the controller for that template:

<?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);

};

Lastly, add the Blueprint to you own blueprints. The one in the plugin is meant to be used as a tab.

Here is a complete list of the things you overide in the controllers, along with the default values for reference:

// Meta
'metatitle'         => $site->title(),
'metadesc'          => $page->seometa(),
'metakeywords'      => $page->seotags(),
'metarobots'        => 'index, follow, noodp',
'metaurl'           => $site->url(),
'metaimage'         => $page->shareimage()->toFile() ? $page->shareimage()->toFile()->crop(1280, 720)->url() : ' ',

// Facebook Meta
'metafbtype'         => 'website',
'metafbsitename'     => $site->title(),
'metafblocale'       => 'en_GB',

// Twitter Meta
'metatwcard'         => 'summary_large_image',
'metatwsite'         => $site->socialtwitterurl()->isNotEmpty() ? $site->socialtwitterurl() : ' ',
'metatwcreator'      => $site->twittercreator()->isNotEmpty() ? $site->twittercreator() : ' ',

I have created the controllers for each page but I placed the snippet in the templates of each page, I think that’s the error. I have header and footer in the snippets folder, should I put the SEO snippet in it?

The snippet should go where ever you have the HTML head tag. Putting it somewhere else wont stop it working and shouldnt throw an error, but meta tags wont be valid unless they are in the head. it will still out put them, but it wont be valid HTML if you put it somewhere else.

If you want to see a working example, its hooked up into my Kirby boilerplate, which is a slightly enhanced version of the Kirby Plain Kit… https://github.com/HashandSalt/ForgeLiteKirby

where should I place the above code?

and should i overwrite the code in the controllers for this?

Replace the controller for the page with the code above. For example, if you wanted to override the meta robots and the meta title, your entire contoller would look something like this:

<?php

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

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

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

  // Override Robots
  $metarobots = 'noindex, nofollow, noodp';

  $data = compact('metatitle', 'metarobots');

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

};

should i ignore this?

Yes, unless you want to override any of them. Those are the variable names to use. Otherwise, the defaults built into the plugin will work for you without configuration from you.

Okay, but I still do not know where to make use of it in case of future project.

Thanks.

Im not sure I understand what you mean. Its the same process for any site.

  1. Install the plugin
  2. Create a controller to match each page template.
  3. Add the included tab from the blueprint to your own blue prints.

This will give you fields in the panel to add the information for each page.

I did all these but i added the blueprint to site.yml, is that the right place to put the blueprint?

This shoud go on page blue prints, not the site blueprint.

It doesn’t override the title