Google offers a service called Google Sitemaps, where you can submit simple XML files to their crawlers to significantly optimize the time they spend navigating your site.  It cuts down on bandwidth (for both parties) and seems to help out your PageRank a little bit.  The file contains just a little bit of information: URL’s to index, how often they update, priorities, etc.  It’s pretty trivial, but sadly not natively supported by GeekLog (yet).

So I managed to hack together a simple piece of PHP that will do it nicely, with some of “RealPanama’s” suggestions.  It assumes alot of defaults, but for a basic start it works pretty well  Anything more would require significant changes to the GeekLog interface & databases (to add the fields for Change Frequency and Priority) which I’m not going to get into.  Hope it helps!

Just save this as sitemap.php in your geeklog root directory.  If you like, you can even create a RewriteRule to change attempts to access “sitemap.xml” to “sitemap.php” .

(code inside, to reduce frontpage clutter)
[tag:geeklog][tag:google][tag:sitemap]

<?php
# Simple Geeklog/Google Sitemap script
# By Yeraze (http://www.yeraze.com)
require_once (‘lib-common.php’);
$display = ”;

   
$result = DB_query(“Select sid, title, unix_timestamp(date) AS day FROM
gl_stories WHERE (date <= NOW()) AND (draft_flag = 0) ORDER BY date
DESC”);
    $nrows = DB_numRows($result);
    $retval .= ‘<?xml version=”1.0″ encoding=”UTF-8″?>’. chr(13) . chr(10);
    $retval .= ‘<urlset xmlns=”http://www.google.com/schemas/sitemap/0.84″‘. chr(13) . chr(10);
    $retval .= ‘xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”‘ . chr(13) . chr(10);
    $retval .= ‘xsi:schemaLocation=”http://www.google.com/schemas/sitemap/0.84′. chr(13) . chr(10);
    $retval .= ‘http://www.google.com/schemas/sitemap/0.84/sitemap.xsd”>’ . chr(13) . chr(10);
    $retval .= ‘<url>’. chr(13) . chr(10);
    $retval .= ‘<loc>’ . $_CONF['site_url'] . ‘</loc>’. chr(13) . chr(10);
    $retval .= ‘<lastmod>’ . date(‘Y-m-d’) . ‘</lastmod>’. chr(13) . chr(10);
    $retval .= ‘<changefreq>daily</changefreq>’. chr(13) . chr(10);
    $retval .= ‘<priority>1.0</priority>’. chr(13) . chr(10);
    $retval .= ‘</url>’. chr(13) . chr(10);

    for ($i = 1; $i <= $nrows; $i++) {
        $A = DB_fetchArray($result);
        $retval .= ‘<url>’. chr(13) . chr(10);
        $retval .= ‘<loc>’ . $_CONF['site_url'] . ‘/article.php/’ . $A['sid'] . ‘</loc>’. chr(13) . chr(10);
        $retval .= ‘<lastmod>’ . date(‘Y-m-d’,$A['day']) . ‘</lastmod>’. chr(13) . chr(10);
        $retval .= ‘<changefreq>weekly</changefreq>’. chr(13) . chr(10);
        $retval .= ‘<priority>0.5</priority>’. chr(13) . chr(10);
        $retval .= ‘</url>’. chr(13) . chr(10);

    }
    $retval .= ‘</urlset>’. chr(13) . chr(10);

    echo $retval;

?>

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • FriendFeed
  • MySpace
  • Netvibes
  • Ping.fm
  • Technorati
  • Tumblr