A standalone search engine result page preview to include in any Kirby project. It allows you to preview how your page will look in the search results of Google and other search engines.
- Kirby 4+
Kirby is not free software. However, you can try Kirby and the Starterkit on your local machine or on a test server as long as you need to make sure it is the right tool for your next project. β¦ and when youβre convinced, buy your license.
composer require johannschopplich/kirby-serp-preview
Download and copy this repository to /site/plugins/kirby-serp-preview
.
Create a new section in one of your blueprints:
sections:
serp-preview:
type: serp-preview
siteTitle: "{{ site.title.value }}"
siteUrl: "{{ site.url }}"
# Optional field to override the computed title
titleContentKey: metaTitle
# Optional default title as fallback if the field above is empty
defaultTitle: "{{ page.getMetaTitle.value }}"
descriptionContentKey: metaDescription
# Optional default description as fallback if the field above is empty
defaultDescription: "{{ site.metaDescription.value }}"
By default, the SERP preview will render the title of the search engine result page preview by joining the following values with a space:
1οΈβ£ Page Title
2οΈβ£ Title Separator (defaults to β
)
3οΈβ£ Site Title
When defaultTitle
is defined
The titleContentKey
section property allows you to define a custom content key for the page's title. If it is set and the field contains a value, it will override the computed title.
Each configuration option is of type string
. Some of them support Kirby queries. For example, you can use {{ site.title.value }}
for the siteTitle
option.
The following table lists all available options:
Option | Default | Queryable | Description |
---|---|---|---|
faviconUrl |
null |
β | The URL to the favicon. |
siteTitle |
"{{ site.title.value }}" |
β | The site title. |
siteUrl |
"{{ site.url }}" |
β | The site URL. |
titleSeparator |
"-" |
β | The title separator between the current page title and the site title. Only applies if no titleContentKey is set and the target field value is empty. |
titleContentKey |
null |
β | The content key for a custom title. |
defaultTitle |
null |
β | Plain text or Kirby query to use as a fallback instead of 1οΈβ£2οΈβ£3οΈβ£ if the titleContentKey is empty. |
descriptionContentKey |
null |
β | The content key for the page's custom description. |
defaultDescription |
null |
β | Plain text or Kirby query to use as a fallback if the descriptionContentKey is empty. |
searchConsoleUrl |
null |
β | If provided, the section will display a link to the Google Search Console. |
MIT License Β© 2023-PRESENT Johann Schopplich
MIT License Β© 2023-PRESENT Dennis Baum