Open main menu

Manual:GenerateSitemap.php

This page is a translated version of the page Manual:GenerateSitemap.php and the translation is 30% complete.

Outdated translations are marked like this.
Other languages:
English • ‎español • ‎polski • ‎русский • ‎中文 • ‎日本語

Contents

Detalles

generateSitemap.php file is a maintenance script to generate a sitemap for a MediaWiki installation. Sitemaps are files that make it more efficient for search engine robots (like googlebot) to crawl a website (so long as the bot supports the sitemap protocol.)

By default, the script generates a sitemap index file and one gzip-compressed sitemap for each namespace that has content. See #Options for a list of options that can be passed to the script.

Puedes necesitar configurar un cron para actualizar automáticamente el sitemap.


Para instrucciones generales sobre cómo usar los scripts de mantenimiento de MediaWiki, véase Manual:Scripts de mantenimiento .

Opciones

--help

displays the available options for generateSitemap.php

--fspath=<path>

The file system path to save to, e.g sitemap/. Note, this directory must be viewable online!

--identifier=<identifier>

What site identifier to use for the wiki, defaults to $wgDBname

--urlpath=<prefix>

The URL that points to --fspath, e.g.
https://wiki.example.com/sitemap/
If specified, gets prefixed to the filenames in the sitemap index. This is needed because some search engines *cough*Google*cough* require absolute URLs in sitemaps. You should specify --server also; the values will often be similar, but having them separate allows the script to accommodate even unusual setups.

--server=<server>

The protocol and host name to use in URLs, e.g.
https://en.wikipedia.org
This is sometimes necessary because server name detection may fail in command line scripts and will show up only as "localhost" or "my.servername" in the xml files.
If set the value of $wgCanonicalServer will override the value of this option in all sitemap files except for the sitemap index file.

--compress=[yes|no]

Whether or not to compress the sitemap files. The default setting is yes.

--skip-redirects

If this option is added redirects are skipped and thus not listed within the sitemap. This is recommended since Google can complain about redirects. However the default setting is not to skip redirects.

Ejemplo

Creating a sitemap for Google Webmaster Tools:

Primero (en $IP):

mkdir sitemap

Luego:

php maintenance/generateSitemap.php --memory-limit=50M --fspath=/path/to/examplecom/sitemap/ --identifier=examplecom --urlpath=https://www.example.com/w --server=https://www.example.com --compress=yes

This example assumes that $wgScriptPath is set to '/w'. Non-latin domains need use Punycode.

Configuraciones relacionadas en LocalSettings.php

Versión de MediaWiki: 1.13
  • $wgSitemapNamespaces : Array of namespaces to generate a Google sitemap for, or false if one is to be generated for all namespaces. The default setting is false.
Versión de MediaWiki: 1.19
  • $wgSitemapNamespacesPriorities : Custom namespace priorities for sitemaps. This should be a map of namespace IDs to priority. The default setting is false.