How to change the method for counting pages as articles in MediaWiki
In MediaWiki some pages are considered content pages, which are also known as articles. This distinction is used for different things. For example, in the site statistics there are separate counts for the articles and for the total number of pages. The tool for selecting a random page selects a page from the content pages (Random page link in the navigation menu or yourdomain.com/index.php/Special:Random).
By default, for a page to be considered an article it should meet three conditions:
- The page shouldn't be a redirect to another page.
- It has to be a page from a content namespace. By default, only the Main namespace is a content namespace. If you want to, you can make other namespaces content ones. For more information on this check out the article on how to turn namespaces into content namespaces in MediaWiki.
- The page has to contain an internal link in its content, meaning that it should link to another page on the site.
The last condition is the subject of this article. With the option $wgArticleCountMethod you can change that condition. There are a few values from which you can select. The value to which the option is set determines the method to be used when counting pages as content pages. In MediaWiki version 1.24 and newer ones it can have one of these values:
- any - all pages in content namespaces are counted as articles
- comma - pages that contain a comma are counted as articles
- link - in the content of the page there should be an internal link to another page
By default, it's set to link. If you want to, you can set the option with one of the other two values. This is done by adding the option to the LocalSettings.php file. For example, if you add the following on a new line at the end of LocalSettings.php:
$wgArticleCountMethod = 'any';
all pages that belong to a content namespace and are not redirects will be counted as articles.
Keep in mind that after you change the article count method, in order for existing pages that meet the new condition to be counted as articles you should update the site statistics. This can be done by executing the script initSiteStats.php. For more information check out the article on how to update the site statistics in MediaWiki.
Note that in MediaWiki versions older than 1.24 the $wgArticleCountMethod option is set to null. In these versions there's also an option $wgUseCommaCount. This option is set to false by default which means that pages should contain a link to be counted as articles; if it's set to true, then they should contain a comma to be considered articles. Of course, if the option $wgArticleCountMethod is set to a different value than null, then this other option will not matter. The option $wgUseCommaCount is removed in version 1.24 and newer ones.
If you haven't edited the LocalSettings.php file and you don't know where it is, you can find it in the root MediaWiki directory on your MediaWiki hosting account. Assuming that the application is installed directly in the public_html directory (making the frontend URL yourdomain.com), then the path to the file on the account in relation to that directory will be public_html/LocalSettings.php. One way for HostKnox customers to edit files is with the file manager of the Pixie control panel. Another way is to download the file on your local computer, edit it with a text editor (e.g. Notepad ++) and upload it back overwriting the old file.
Was this answer helpful?
- How to select the default namespaces to be searched by the search function in MediaWiki
- How to remove "Powered by MediaWiki" from the footer in MediaWiki
- How to rebuild the Recent changes list in MediaWiki
- How to change the font family, size and color of text in MediaWiki
- How to disable the options for user preferences in MediaWiki