Google Sitemaps for MediaWiki

From LemonWiki共筆
Jump to: navigation, search

<< MediaWiki

"The Sitemap Protocol allows you to inform search engines about URLs on your websites that are available for crawling." (Quoted from Google Sitemap Protocol) Google Sitemaps for MediaWiki list all URLs of wiki pages for crawling,

MediaWiki v.1.4, 1.11.0+



Installation[edit]


Troubleshooting: URL are the same http://wiki.example.com/[edit]

URLs of wiki page <loc> at Sitemap file are the same URL: http://wiki.example.com/ not the correct URL of each wiki page: http://wiki.example.com/index.php/Page_Name

The correct Sitemap may appeared as follows (Sitemap Protocol):

   < url>
    < loc>http://wiki.example.com/index.php/Page_Name</loc>
    < lastmod>2005-01-01</lastmod>
    < changefreq>monthly</changefreq>
    < priority>1</priority>
   </url>  

I modified the partial code as follows:

original code[edit]

# -----------------------------------------------------
# Start output
# -----------------------------------------------------

?>
	<url>
		<loc><?php echo fnXmlEncode( "http://" . $wgServerName . eregi_replace('\$1',$sPageName,$wgArticlePath) ) ?></loc>
		<lastmod><?php echo fnTimestampToIso($row_rsPages['page_touched']); ?></lastmod>
		<changefreq>weekly</changefreq>
		<priority><?php echo $nPriority ?></priority>
	</url>
<?php } while ($row_rsPages = mysql_fetch_assoc($rsPages)); ?>
</urlset> 


modified code[edit]

# -----------------------------------------------------
# Start output
# -----------------------------------------------------

?>
	<url>
		<loc><?php echo fnXmlEncode( "http://" . $wgServerName ) ?>/index.php/<?php echo fnXmlEncode( $sPageName ) ?></loc>
		<lastmod><?php echo fnTimestampToIso($row_rsPages['page_touched']); ?></lastmod>
		<changefreq>weekly</changefreq>
		<priority><?php echo $nPriority ?></priority>
	</url>
<?php } while ($row_rsPages = mysql_fetch_assoc($rsPages)); ?>
</urlset>


Further reading