Mediawiki 生成google sitemap

时间:2022-05-03
本文章向大家介绍Mediawiki 生成google sitemap,主要内容包括Extension:Google Sitemap、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

首先,看扩展:

Extension:Google Sitemap

在扩展页面看到下面的说明:

Note: Since MediaWiki 1.6, the MediaWiki core has a Google site map generator which may be more appropriate than this extension. It is a command-line utility, and it is located at maintenance/generateSitemap.php in your MediaWiki directory. The command line is "php generateSitemap.php sitename" and is run from the maintenance directory at the server's command line interface. See Manual:generateSitemap.php for more information.

自mediawiki 1.6版本,mediawiki 核心已经包含了一个google site map 生成器,是个命令行工具,包含下面的参数

Options

--help

显示帮助  generateSitemap.php

--fspath=<path>

指定sitemap保存路径, e.g /tmp/sitemap/

--urlpath=<prefix>

url前缀 --fspath, e.g. http://wiki.example.com/sitemap/不过这个玩意在1.16的版本里还没有,需要自己修改下代码,或者从svn签出最新的代码--server=<server>mediawiki的服务器 e.g. http://en.wikipedia.org最好指定这个参数,不然会读取服务器的名字,如果你的服务器名字和网站域名不一致的话,生成的url就不对了This is sometimes necessary because server name detection may fail in command line scripts and will show up only as "localhost" in the xml files. (included in 1.12.0; may not be included in 1.14.0 (verification needed)

--compress=[yes|no]

是否压缩,选择yes的话会将sitemap压缩

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

实战举例:生成codingwiki.info编程百科sitemap

php generateSitemap.php --fspath /home/wwwroot/codingwiki/sitemap/ --urlpath http://codingwiki.info/sitemap/ --server http://codingwiki.info --compress no

生成结果如下:

其中sitemap-index-codingwiki-codingwiki_.xml是sitemap的索引页面,将这个页面提交给google就可以了

PS,codingwiki.info使用的是burst的vps,$5.95/MONTH,性价比不错,有需要的同学可以点下面的链接去购买,用paypal支付就可以

https://service.burst.net/aff.php?aff=1406