Semantic MediaWiki and related extensions
Usage
image

In order to generate customized <meta> tags, property assignments have to be added to `$GLOBALS['smtgTagsProperties'](no assigments = no additional <meta>` tags).

<meta> tags are mapped (by name) to properties. In case you want to generate multiple values from different properties to the same <meta> tag then separate those property assigments by comma.

If a tag contains a og: it is identified as an [Open Graph][opg] <meta> tag and annotated using the meta property="" description.

Configuration

Example settings

Simple settings

Best for wikis using templates on all content pages

$GLOBALS['smtgTagsProperties'] = [
// Standard meta tags
'keywords' => [
'Has keywords', 'Has another keyword'
],
'description' => 'Has some description',
'author' => 'Has last editor',
// Summary card tag
'twitter:description' => 'Has some description',
// Open Graph protocol supported tag
'og:title' => 'Has title'
];
$GLOBALS['smtgTagsStrings'] = [
// Static content tag
'some:tag' => 'Content that is static'
];
$GLOBALS['smtgMetaPropertyPrefixes'] = [
// Open Graph prefixes
'og:',
'fb:'
];

Advanced settings

Best for wikis not using templates on all content pages

$GLOBALS['smtgTagsProperties'] = [
// Standard meta tags
'keywords' => [
'Has keywords',
'Has another keyword',
function( OutputPage $outputPage ): string {
// Redirects to the page are collected as keywords.
$redirects = $outputPage->getContext()->getTitle()->getRedirectsHere();
$redirect_titles = [];
foreach ( $redirects as $redirect ) {
$redirect_titles[] = $redirect->getText();
}
return implode( ', ', array_unique( $redirect_titles ));
}
],
'description' => [
'Has some description',
function( OutputPage $outputPage ): string {
global $wgLanguageCode;
$title = $outputPage->getContext()->getTitle()->getText();
$main_page = wfMessage( 'mainpage' )->inLanguage( $wgLanguageCode ?: 'ru' )->escaped();
$site_name = wfMessage( 'pagetitle-view-mainpage' )->inLanguage( $wgLanguageCode ?: 'ru' )->escaped();
$subtitle = $title !== $main_page ? wfMessage( 'tagline' )->inLanguage( $wgLanguageCode ?: 'ru' )->escaped() : '';
return $title === $main_page ? $site_name : $title . '. ' . $subtitle;
}],
'author' => 'Has last editor',
// Summary card tag
'twitter:description' => 'Has some description',
// Open Graph protocol supported tag
'og:title' => 'Has title'
];
$GLOBALS['smtgTagsPropertyFallbackUsage'] = true;
$GLOBALS['smtgTagsStrings'] = [
// Static content tag
'some:tag' => 'Content that is static'
];
$GLOBALS['smtgMetaPropertyPrefixes'] = [
// Open Graph prefixes
'og:',
'fb:'
];

About | General disclaimer | Privacy policy