Skip Navigation
Docs

Installation & Setup

Installation

Composer is the recommended way to install Kirby SEO. Run the following command in your terminal:

composer require tobimori/kirby-seo

Alternatively, you can download and copy this repository to /site/plugins/kirby-seo, or apply this repository as Git submodule. Support will not be provided for manual installations.

Adding blueprint tabs

Add the blueprint tabs to your blueprints.

# site/blueprints/site.yml
tabs:
  content:
    fields:
      # your fields
  seo: seo/site
# site/blueprints/pages/default.yml (or any other template)
tabs:
  content:
    fields:
      # your fields
  seo: seo/page

The site-level fields are required. You can add the page-level fields to any template that you want editors to have control over the SEO settings for this page, they're not required for the page to be working with Kirby SEO (it will fall back as the cascade describes).

Adding meta snippet

Add the meta snippet to your templates:

// site/templates/default.php
<html lang="<?= $site->lang() ?>">
  <head>
    <?php snippet('seo/head'); ?>
  </head>
  <body>
    [...]
    <?php snippet('seo/schemas'); ?>
  </body>
</html>

The seo/head snippet will output all meta tags, including the <title> tag. The seo/schemas snippet will output all JSON-LD schemas.

It's important to place the seo/head snippet in the <head> tag, and the seo/schemas snippet at the end of the <body> tag.

Setting your canonical URLs

The canonical URL is the URL that you want search engines to index. It's important to set it correctly, otherwise you might get penalized for duplicate content - especially if you run your site both with and without www.

You can set the canonical URL in your config file:

// site/config/config.php
return [
    'tobimori.seo.canonicalBase' => 'https://www.example.com',
];

You can also supply a function that returns the canonical URL. This is helpful for specialized setups that run explicitly on multiple domains.

While there is a graceful fallback for this to the $site->url() method, it's just safer to set it explicitly to prevent any configuration hickups to penalize your site indexing.

Single-Language Setup

If you're using a single-language setup, it's important to define the language code of your website in the config file:

// site/config/config.php
return [
    'tobimori.seo.lang' => 'en_US',
];

It's used for the og:locale meta tag, and can be applied to the lang attribute of your <html> tag using the $site->lang() site method.

Support Kirby SEO development:
Get a Stay Awesome License

Kirby SEO is available completely free of charge.
If you’re using it to deliver a commercial project, please consider supporting further development & maintenance financially.

Sponsor