Kirby SEO plugin

Just pushed out my own solution to generating meta tags for SEO and social media sharing.

It’s great used in tandem with my schema plugin:

4 Likes

Hi,
I am a pb with plugin. Undefined variable: metatitle when à add the snippet in the snippet header.
A solution ?

Welcome to the forum @morganpouco :slight_smile:

It sounds like you are missing a controller. You can read about these here… https://getkirby.com/docs/guide/templates/controllers

To fix it, you need create a controller in site/contollers that matches the name of your templates. You need one for each template you have in site/templates.

So for default.php template, the controller will look something like this:

<?php

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

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

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

  // Pass through data
  $data = compact('metatitle');

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

};

This brings in the shared controller from the plugin and makes its variables available to the page template.

I hope that helps :slight_smile:

1 Like

Thx for the help. It’s ok for me now ! :wink:

Smashing :slight_smile:

1 Like