Google Sitemaps for MediaWiki

From LemonWiki共筆
Revision as of 08:04, 24 October 2009 by Planetoid (talk | contribs) (復原由94.179.247.244 (對話)的編輯;更改回WikiSysop的最後一個版本)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to 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