Extension:WikiSEO

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
WikiSEO
Release status: stable
Implementation Parser function
Description Allows to change the title and the meta keyword/description tags.
Author(s) Andru Vallance (Andrujhontalk)
Latest version 1.2.2 (2018-01-08)
MediaWiki 1.25+
PHP 5.4+
Database changes No
Composer tinymighty/wiki-seo
License GNU General Public License 2.0 or later
Download
README
Parameters
  • $wgGoogleSiteVerificationKey
  • $wgFacebookAdmins
  • $wgFacebookAppID
  • $wgAddJSONLD
Tags
* <seo></seo>
Hooks used
ParserFirstCallInit
BeforePageDisplay
OutputPageBeforeHTML
Translate the WikiSEO extension if it is available at translatewiki.net
Check usage and version matrix.

The WikiSEO extension allows you to replace, append or prepend the html title tag content, and allows you to add meta keywords and a meta description.

Installation[edit]

Automated Installation with Composer[edit]

This is possible starting with MediaWiki 1.22 and later. Follow the instructions at the Composer help page to add the package tinymighty/wiki-seo to your composer.json file.

Manual Installation[edit]

  • Download and place the file(s) in a directory called WikiSEO in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'WikiSEO' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension() If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'WikiSEO' );, you need to use:

require_once "$IP/extensions/WikiSEO/WikiSEO.php";
If you are installing the extension via a Git clone, be sure to specify the directory name as WikiSEO:
cd extensions

git clone https://github.com/tinymighty/wiki-seo.git WikiSEO

cd WikiSEO

git checkout 1.2.2

Usage[edit]

The extension can be used via the <seo> tag or the {{#seo}} parser function. Both accept the following named parameters in any order.

tags for general use
  • title
The title you want to appear in the html title tag
  • titlemode
Set to append, prepend, or replace (default) to define how the title will be amended.
  • titleseparator
The separator in case titlemode was set to append or prepend; "-" (default)
  • keywords
A comma separated list of keywords for the meta keywords tag
  • description
A text description for the meta description tag
  • google-site-verification
The Google site verification tag used by Google Webmaster Tools
Note Note: This only needs to be added to your wiki's home page. This is the page that your server returns when someone requests your site (such as e.g. http://www.example.com/wiki/)[1][2]
tags related to the Open Graph protocol[3][4]
  • og:type
The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.
  • og:image
An image URL which should represent your object within the graph.
  • og:site_name
If your object is part of a larger web site, the name which should be displayed for the overall site. e.g., "IMDb".
  • og:locale
The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.
tags related to Open Graph type "article" [5]
  • article:author
  • article:publisher
  • article:tag
  • article:section
tags related to Facebook Insights[6]
  • fb:admins
  • fb:app_id
tags related to Twitter Cards[7]
  • twitter:card
  • twitter:site
  • twitter:domain
  • twitter:creator
  • twitter:image:src
  • twitter:description

Examples[edit]

Adding static values[edit]

{{#seo:
|title=Your page title
|titlemode=append
|keywords=these,are,your,keywords
|description=Your meta description
}}

or

<seo title="Your page title" titlemode="append" keywords="these,are,your,keywords" description="Your meta description"></seo>

Adding dynamic values[edit]

If you need to include variables or templates you should use the parser function to ensure they are properly parsed. This allows you to use Cargo or Semantic MediaWiki, with Page Forms, for data entry, or for programmatic creation of a page title from existing variables or content...

{{#seo:
 |title={{#if: {{{page_title|}}} | {{{page_title}}} | Welcome to WikiSEO}}
 |titlemode={{{title_mode|}}}
 |keywords={{{keywords|}}}
 |description={{{description|}}}
 }}

See also[edit]

This extension has been rewritten to current MediaWiki standards based on the Add HTML Meta and Title extension by Vladimir Radulovski. As I have also made some design changes, I have released it as a separate extension, but it is backwards compatible (it provides a <seo> tag, and permits the use of the metakeywords, metak, metadescription and metad attributes.

Notes[edit]