Download the PHP package pedroborges/kirby-meta-tags without Composer
On this page you can find all versions of the php package pedroborges/kirby-meta-tags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pedroborges/kirby-meta-tags
More information about pedroborges/kirby-meta-tags
Files in pedroborges/kirby-meta-tags
Package kirby-meta-tags
Short Description HTML meta tags generator for Kirby 3.
License MIT
Homepage https://github.com/pedroborges/kirby-meta-tags
Informations about the package kirby-meta-tags
Kirby Meta Tags
HTML meta tags generator for Kirby. Supports Open Graph, Twitter Cards, and JSON Linked Data out of the box.
Requirements
- Kirby 3
- PHP 7.1+
Installation
Download
Download and copy this repository to site/plugins/meta-tags
.
Git submodule
Composer
For Kirby 2, you can download v1.1.1 and copy the files to
site/plugins/meta-tags
.
Basic Usage
After installing the Meta Tags plugin, you need to add one line to the head
element on your template, or header.php
snippet:
By default the metaTags
page method will render all tag groups at once. But you can also render only one tag at a time:
Or specify which tags to render:
Default
The plugin ships with some default meta tags enabled for your convenience:
The pedroborges.meta-tags.default
option is applied to all pages on your Kirby site. Of course you can change the defaults. In order to do that, just copy this example to your site/config/config.php
file and tweak it to fit your website needs.
Templates
Following the flexible spirit of Kirby, you also have the option to add template specific meta tags:
In the example above, those settings will only be applied to pages which template is song
.
For more information on all the meta
, link
, Open Graph and Twitter Card tags available, check out these resources:
Options
Both the pedroborges.meta-tags.default
and pedroborges.meta-tags.templates
accept similar values:
pedroborges.meta-tags.default
It accepts an array containing any or all of the following keys: title
, meta
, link
, og
, and twitter
. With the exception of title
, all other groups must return an array of key-value pairs. Check out the tag groups section to learn which value types are accepted by each key.
pedroborges.meta-tags.templates
This option allows you to define a template specific set of meta tags. It must return an array where each key corresponds to the template name you are targeting.
When a key matches the current page template name, it is merged and overrides any repeating properties defined on the pedroborges.meta-tags.default
option so you don't have to repeat yourself.
Tag Groups
These groups accept string, closure, or array as their values. Being so flexible, the sky is the limit to what you can do with Meta Tags!
title
Corresponds to the HTML <title>
element and accepts a string
as value.
You can also pass it a
closure
that returns astring
if the logic to generate thetitle
is more complex.
meta
The right place to put any generic HTML <meta>
elements. It takes an array
of key-value pairs. The returned value must be a string
or closure
.
Show HTML 👁
link
This tag group is used to render HTML <link>
elements. It takes an array
of key-value pairs. The returned value can be a string
, array
, or closure
.
Show HTML 👁
og
Where you can define Open Graph <meta>
elements.
Show HTML 👁
Of course you can use Open Graph structured objects. Let's see a blog post example:
Show HTML 👁
Use the namespace:
prefix for structured properties:
author
insidenamespace:article
becomesog:article:author
.image
insidenamespace:image
becomesog:image
.width
insidenamespace:image
becomesog:image:width
.
When using Open Graph tags, you will want to add the
prefix
attribute to thehtml
element as suggested on their docs:<html prefix="og: http://ogp.me/ns#">
twitter
This tag group works just like the previous one, but it generates <meta>
tags for Twitter Cards instead.
Show HTML 👁
json-ld
Use this tag group to add JSON Linked Data schemas to your website.
If you leave them out,
http://schema.org
will be added as@context
and the array key will be added as@type
.
Show HTML 👁
Change Log
All notable changes to this project will be documented at: https://github.com/pedroborges/kirby-meta-tags/blob/master/CHANGELOG.md
License
The Meta Tags plugin is open-sourced software licensed under the MIT license.
Copyright © 2019 Pedro Borges [email protected]
All versions of kirby-meta-tags with dependencies
getkirby/composer-installer Version ^1.1
pedroborges/meta-tags Version ^0.0.2