Extension:DynamicWikiSitemap

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
DynamicWikiSitemap
Release status: stable
Implementation Data extraction
Description Adds a separate sitemap page.
Author(s) Simon Litt (SimonLitttalk)
Latest version 1.0.1 (2013-03-02)
MediaWiki 1.15+
Database changes No
License GPL
Download Download code
Parameters
  • $wgDynamicWikiSitemapExclude
  • $wgDynamicWikiSitemapServerBase
  • $wgDynamicWikiSitemapExcludeSites
  • $wgDynamicWikiSitemapArticlePriority
  • $wgDynamicWikiSitemapEstimateChangeFreq
  • $wgDynamicWikiSitemapLimit
  • $wgDyamicWikiSitemapSortingCriterion
  • $wgDynamicWikiSitemapShortUrl
Translate the DynamicWikiSitemap extension if it is available at translatewiki.net
Check usage and version matrix.

The DynamicWikiSitemap extensions adds a separate sitemap page. It will update itself automatically, which is useful if you update your website on a regular basis.

This extension does not provide a special page.

The XML file has the following properties:

  • it is sorted by decreasing article popularity (ie. highest number of hits). However, you can configure it.
  • it contains articles only : no redirection pages, nor any other special/external page. However, you can configure it.

In order to produce more relevant Sitemaps, DynamicWikiSitemap Extension can also estimate the revision frequency of your pages and associate them a priority according various schemes.

Installation[edit]

Download the latest version and extract it into the root directory of your MediaWiki installation(the same directory that holds LocalSettings.php).

Note: No need to register the sitemap.php at LocalSettings.php(there you can only set configuration).

Note: The extension works properly only when installed in the root directory.

These actions is enough to install, but you can use URL Rewriting to make it URL more clean and simple.

URL Rewriting[edit]

First, create a .htaccess file, located at the root directory, or modify the .htaccess file you may already have:

Options +FollowSymlinks
RewriteEngine on
 
# Link for the Sitemap
RewriteRule ^sitemap(.*)\.xml$ sitemap.php?page=$1 [L,NC]

If your wiki is not installed in the root folder of the site, and installed for example a folder /w/, /wiki/ or in any other, the URL Rewriting will look like this:

Options +FollowSymlinks
RewriteEngine on
 
# Link for the Sitemap
RewriteRule ^folder_in_which_you_installed_wiki/sitemap(.*)\.xml$ /folder_in_which_you_installed_wiki/sitemap.php?page=$1 [L,NC]

If, for example, on your website (example.com) has multiple wiki in different folders (example.com/wiki1), (example.com/wiki2), then the URL Rewriting will look like this:

Options +FollowSymlinks
RewriteEngine on
 
# Link for the Sitemap
RewriteRule ^wiki1/sitemap(.*)\.xml$ /wiki1/sitemap.php?page=$1 [L,NC]
RewriteRule ^wiki2/sitemap(.*)\.xml$ /wiki2/sitemap.php?page=$1 [L,NC]

Sitemap.php[edit]

If your wiki is not installed in the root folder of the site, you need to adjust a little file sitemap.php. To do this, open it (Notepad or any text editor such as Notepad++), then find the line:

class DynamicWikiSitemap{
	var $DEFAULT_SITEMAP_STYLE = '/sitemap.xsl';
	var $DEFAULT_SITEINDEX_STYLE = '/siteindex.xsl';

And to add to them the path to the file:

class DynamicWikiSitemap{
	var $DEFAULT_SITEMAP_STYLE = '/folder_in_which_you_installed_wiki/sitemap.xsl';
	var $DEFAULT_SITEINDEX_STYLE = '/folder_in_which_you_installed_wiki/siteindex.xsl';

Well, if your site has multiple wikis that in different folders /wiki1/, /wiki2/, you'll have to change the file path in each file sitemap.php.

Robots.txt[edit]

Do not forget to add to your robots.txt link to the site map. To do this, edit it by adding to the bottom line:

Sitemap: http://example.com/sitemap.xml

If your wiki is not installed in the root folder of the site, then the path to the map will look like this:

Sitemap: http://example.com/folder_in_which_you_installed_wiki/sitemap.xml

If your site has more than one wiki, you should specify the path to each map:

Sitemap: http://example.com/wiki1/sitemap.xml
Sitemap: http://example.com/wiki2/sitemap.xml

LocalSettings.php[edit]

Then add the following lines to your LocalSettings.php file (near the end):

$wgDynamicWikiSitemapShortUrl = "sitemap$1.xml";


This way, sitemap.php will allow us to automatically generate the content of the XML file (the real Sitemap). Each time search engine will try to open sitemap.xml, sitemap.php will be executed and will make an update of the XML file.

Configuration parameters[edit]

There are various options for extension, you can put them into your LocalSettings.php file line. However, extension should work even out-of box.

Exclude types of pages from sitemap[edit]

$wgDynamicWikiSitemapExclude
an array defining the excluded namespaces.
$wgDinamicWikiSitemapExclude
an array defining the excluded namespaces. Deprecated as of 0.1.3 version, July 2011 use $wgDynamicWikiSitemapExclude instead.
# Exclude pages from sitemap (value "1" means "exclude"):

#Please refer to
#http://www.mediawiki.org/wiki/Help:Namespaces
#for more detailed explanation
$wgDynamicWikiSitemapExclude=array();
$wgDynamicWikiSitemapExclude[-2]=1;# Media, links to just the image rather than the image description page
$wgDynamicWikiSitemapExclude[-1]=1;# Special pages
$wgDynamicWikiSitemapExclude[0]=0;#  Simple page
$wgDynamicWikiSitemapExclude[1]=0;#  Discussion page
$wgDynamicWikiSitemapExclude[2]=0;#  User page
$wgDynamicWikiSitemapExclude[3]=1;#  User Talk page
$wgDynamicWikiSitemapExclude[4]=0;#  Project page
$wgDynamicWikiSitemapExclude[5]=0;#  Project talk page
$wgDynamicWikiSitemapExclude[6]=0;#  File
$wgDynamicWikiSitemapExclude[7]=0;#  File Talk
$wgDynamicWikiSitemapExclude[8]=1;#  System messages and other important content. Already Excluded.
$wgDynamicWikiSitemapExclude[9]=1;#  Discussions related to the associated system messages. Already Exluded.
$wgDynamicWikiSitemapExclude[10]=1;# Templates
$wgDynamicWikiSitemapExclude[11]=1;# Discussions related to the associated template pages
$wgDynamicWikiSitemapExclude[12]=0;# Help files, instructions and 'how-to' guides
$wgDynamicWikiSitemapExclude[13]=0;# Discussions related to the associated help pages
$wgDynamicWikiSitemapExclude[14]=1;# Categories, dynamic lists of other pages
$wgDynamicWikiSitemapExclude[15]=1;# Discussions related to the associated category pages

Setting base url other than $wgServer[edit]

$wgDynamicWikiSitemapServerBase
base url.
$wgDinamicWikiSitemapServerBase
base url. Deprecated as of 0.1.3 version, July 2011 use $wgDynamicWikiSitemapServerBase instead.
$wgDynamicWikiSitemapServerBase = "http://your-base-url.com";
#With that all sitemap entries get this as their base url. If not set $wgServer is used

Exclude pages from sitemap by name[edit]

$wgDynamicWikiSitemapExcludeSites
an array defining the excluded pages.
$wgDinamicWikiSitemapExcludeSites
an array defining the excluded pages. Deprecated as of 0.1.3 version, July 2011 use $wgDynamicWikiSitemapExcludeSites instead.
$wgDynamicWikiSitemapExcludeSites[] = 'page title to exclude';
#or
$wgDynamicWikiSitemapExcludeSites = array('page1 title to exclude', 'page2 title to exclude');
#to exclude some pages from the sitemap. The pages exclude name must be equal to the name/title shown at the Special:ManualSitemap site.

Setting priority[edit]

$wgDynamicWikiSitemapArticlePriority
the priority scheme to use in a <priority> tag. Default is DWS_PRIORITY_CONSTANT.
$wgDinamicWikiSitemapArticlePriority
the priority scheme to use in a <priority> tag. Deprecated as of 0.1.3 version, July 2011 use $wgDynamicWikiSitemapArticlePriority instead.

You can use following priority schemes:

constant
all priorities is 0.5 (configuration constant DWS_PRIORITY_CONSTANT);
linear
(configuration constant DWS_PRIORITY_LINEAR);
quadratic
(configuration constant DWS_PRIORITY_QUADRATIC);
cubic
(configuration constant DWS_PRIORITY_CUBIC);
exponential
(configuration constant DWS_PRIORITY_EXPONENTIAL);
smooth
(configuration constant DWS_PRIORITY_SMOOTH);
random
(configuration constant DWS_PRIORITY_RANDOM);
reverse
(configuration constant DWS_PRIORITY_REVERSE).

See various schemes for details.

$wgDynamicWikiSitemapArticlePriority = DWS_PRIORITY_CONSTANT;

Setting change frequencies[edit]

$wgDynamicWikiSitemapEstimateChangeFreq
enable to estimate the revision frequency. Default is false.
$wgDinamicWikiSitemapEstimateChangeFreq
enable to estimate the revision frequency. Deprecated as of 0.1.3 version, July 2011 use $wgDynamicWikiSitemapEstimateChangeFreq instead.
$wgDynamicWikiSitemapEstimateChangeFreq = true;
# Enables to estimate the revision frequency

Setting sitemap limit[edit]

$wgDynamicWikiSitemapLimit
maximum number of articles at a sitemap page. Default is 10000.
$wgDinamicWikiSitemapLimit
maximum number of articles at a sitemap page. Deprecated as of 0.1.3 version, July 2011 use $wgDynamicWikiSitemapLimit instead.

Note: At exceeding the number of pages, the sitemap works at sitemap index mode.

$wgDynamicWikiSitemapLimit = 500;
#The sitemap page will build with the 500 articles

Setting sorting criterion[edit]

$wgDynamicWikiSitemapSortingCriterion
the sorting criterion of sitemap articles. Default is DWS_SORTING_POP.
$wgDinamicWikiSitemapSortingCriterion
maximum number of articles at a sitemap page. Deprecated as of 0.1.3 version, July 2011 use $wgDynamicWikiSitemapSortingCriterion instead.

You can use following sorting schemes:

popularity
sort descending by popularity (configuration constant DWS_SORTING_POP)
last revision
sort descending by last revision (configuration constant DWS_SORTING_REV)
page ID
sort descending by page ID (configuration constant DWS_SORTING_PAGE_ID)

Note: At mode with sitemap index available only DWS_SORTING_PAGE_ID sorting scheme.

$wgDynamicWikiSitemapSortingCriterion = DWS_SORTING_POP;

Setting short URL[edit]

$wgDynamicWikiSitemapShortUrl
The base URL used to create sitemap page links at sitemap index mode.

Note: Requires URL Rewriting configuration.

$wgDynamicWikiSitemapShortUrl = "sitemap$1.xml";

Notes[edit]

  • Code of this extension is based on Extension:ManualSitemap extension.
  • DynamicWikiSitemap works with both MySQL and INNODB installations.


See also[edit]


Other languages: English  • русский