Manual:Noindex

From Linux Web Expert

Revision as of 02:23, 16 October 2023 by imported>Valerio Bozzolan (move text in useful sections, more prominent to newcomers I hope)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Noindex can be used to prevent indexing of a page by search engines.

Using Wikitext

To change the index preferences for specific pages, use one of these magic words:

  • __INDEX__
  • __NOINDEX__

These magic words work for a given namespace. One may need to adjust $wgExemptFromUserRobotsControl.

To test whether they function for a given page, you can use the PHP function Title::canUseNoindex().

Using site Configuration

There are some site configurations that can be set. Some of them:

Using PHP

An example code in PHP, for example to be used by extension developers, would be:

$wgOut->setRobotPolicy('noindex,nofollow');

Or, if one wished to be more selective:

$wgOut->setIndexPolicy('noindex');

See also