Minimal SEO plugin for Kirby CMS
- Meta tags (title, description, keywords, robots, canonical URL)
- Open Graph tags (title, type, site name, URL, image, description, locale)
- Twitter Card tags (title, card, site, creator, image, description)
- Automatic image cropping to 1200x630 for social sharing
- Panel blueprints for page-level and site-level SEO fields
- Multi-language support (locale detection)
- Conditional rendering (empty fields produce no HTML output)
- PHP ^8.2
- Kirby ^4.0.1 or ^5.0
composer require benjaminhaeberli/kirby-seoIn your site.yml blueprint, include the SEO fields for global settings (site title, OG image, Twitter handles):
# site/blueprints/site.yml
tabs:
seo:
label: SEO
fields:
seo: fields/seo/siteIn any page blueprint, include the SEO fields (meta title, description, keywords, canonical URL):
# site/blueprints/pages/default.yml
tabs:
seo:
label: SEO
fields:
seo: fields/seo/metaIn your header.php snippet (or equivalent), add the SEO snippet inside <head>:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php snippet('seo/meta') ?>
</head>The snippet generates the following HTML (tags with empty values are omitted):
<base href="https://example.com">
<title>Page title</title>
<meta content="Page description." name="description">
<meta content="keyword1, keyword2" name="keywords">
<meta content="index, follow, noodp" name="robots">
<link href="https://example.com/canonical" rel="canonical">
<meta content="Page title" property="og:title">
<meta content="website" property="og:type">
<meta content="My Site" property="og:site_name">
<meta content="https://example.com/page" property="og:url">
<meta content="https://example.com/image.jpg" property="og:image">
<meta content="Page description." property="og:description">
<meta content="fr_FR" property="og:locale">
<meta content="Page title" name="twitter:title">
<meta content="summary_large_image" name="twitter:card">
<meta content="@site" name="twitter:site">
<meta content="@creator" name="twitter:creator">
<meta content="https://example.com/image.jpg" name="twitter:image">
<meta content="Page description." name="twitter:description">| Field | Type | Description |
|---|---|---|
| Site title | text |
Used as og:site_name |
| Image | files |
OG/Twitter image (cropped to 1200x630) |
| Twitter (Creator) | text |
@handle of the content author |
| Twitter (Site) | text |
@handle of the website |
| Field | Type | Description |
|---|---|---|
| Meta title | text |
<title> and og:title |
| Meta description | textarea |
<meta name="description"> and og:description |
| Keywords | tags |
<meta name="keywords"> |
| Canonical URL | url |
<link rel="canonical"> (defaults to site URL) |
Blueprint labels and help texts use Kirby's plugin translations system. English and French are included.
To add a new language, create a file in translations/ (e.g. de.php) following the same format as en.php, and register it in index.php. Contributions are welcome via pull request.
composer install
composer test # Run all checks (rector, pint, phpstan, pest)
composer test:unit # Run Pest tests only
composer test:types # Run PHPStan only
composer lint # Run Pint code formatter
composer refacto # Run Rector refactoring