Adds social media meta tags to Silverstripe sites.
Adds social media meta tags to Silverstripe sites.
silverstripe-social-meta-tags adds social media meta tags for OpenGraph (Facebook) and Twitter to SiteTree and child page types.
Supported social media meta tags include:
og:site_name
og:title
og:image
og:description
og:url
twitter:site
twitter:title
twitter:image
twitter:description
twitter:card
SilverStripe 4.2+
Use the 1.0
tag (ss3 branch) for SilverStripe 3 sites.
composer require innis-maggiore/silverstripe-social-meta-tags ^4.0
/dev/build?flush=all
By default, the module will use the following fields to populate the meta tags:
og:type
--> "website"
og:site_name
--> SiteConfig.Title
og:title
--> Title
og:description
--> MetaDescription
og:url
--> AbsoluteLink()
twitter:title
--> Title
twitter:description
--> MetaDescription
twitter:card
--> "summary"
NOTE: twitter:card
will be set to "summary"
by default, unless an image field is used. If an image field is used, the content will be set to "summary_large_image"
.
Configure the module by editing mysite/_config/config.yml
and set the following options:
InnisMaggiore\SocialMetaTags:
default_title: 'Title'
default_description: 'MetaDescription'
meta_description_default: true
twitter_site: ''
titles:
Fully\Namespaced\ClassName: 'FieldName'
Fully\Namespaced\ClassName1: 'FieldName1'
descriptions:
Fully\Namespaced\ClassName: 'FieldName'
Fully\Namespaced\ClassName1: 'FieldName1'
images:
Fully\Namespaced\ClassName: 'FieldName'
Fully\Namespaced\ClassName1: 'FieldName1'
types:
Fully\Namespaced\ClassName: 'website'
Fully\Namespaced\ClassName1: 'article'
default_title
- override the default title field to use; PageTitle
is used by default.default_description
- override the default description field to use; MetaDescription
is used by default.meta_description_default
- flag that indicates whether to fall back to MetaDescription
if the chosen description field is empty.twitter_site
- the content to be used for thw twitter:site
meta tag.titles
- an array of class names, with the value being the name of the Text field to use for title meta tags. Useful for adding social media meta tag output to DataObjects.descriptions
- an array of class names, with the value being the name of the Text field to use for description meta tags. Useful for adding social media meta tag output to DataObjects.images
- an array of class names, with the value being the name of the Image field to use for image meta tags. Useful for adding social media meta tag output to DataObjects.types
- an array of class names, with the value being the content to use for og:type
met tag.config.yml
InnisMaggiore\SocialMetaTags:
default_title: 'PageTitle'
default_description: ''
meta_description_default: true
titles:
InnisMaggiore\Models\Category: 'Name'
InnisMaggiore\Models\Product: 'Name'
InnisMaggiore\Models\Recipe: 'Name'
descriptions:
InnisMaggiore\Models\Category: 'ShortDescr'
InnisMaggiore\Models\Product: 'Summary'
InnisMaggiore\Models\Recipe: 'MetaDescription'
images:
InnisMaggiore\Pagetypes\AboutUsPage: 'LogoImage'
InnisMaggiore\Models\Category: 'BeautyShot'
InnisMaggiore\Models\Product: 'BeautyShot'
InnisMaggiore\Models\Recipe: 'Image'
types:
InnisMaggiore\Models\Recipe: 'article'
twitter_site: ''
By default, this module will only add social media meta tags to SiteTree objects.
To add social media meta tags to DataObjects:
_config/config.yml
, add the extension to each DataObject class you wish:Fully\Namespaced\Dataobject:
extensions:
- InnisMaggiore\SilverstripeSocialMetaTags\SocialMetaTagsExtension
_config/config.yml
, set options for titles
, descriptions
, and images
(if desired) for your class.
config.yml
.getCMSFields()
: public function getCMSFields() {
$fields = parent::getCMSFields();
...
$fields->addFieldToTab('Root.Main', new TextareaField("SocialMetaDescription"));
$fields->addFieldToTab('Root.Main', new UploadField("SocialMetaImage"));
return $fields;
}
/dev/build?flush=all
This project is licensed under the New BSD License
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem