I'll be talking specifically today about adding a blogroll to your Blogger powered site, but even if you're not interested in doing that, this might be worth a read for some other principles that will be illustrated.

To start off with, let me point out the WRONG way to add a blogroll to your blog. Do NOT hard code it into your blog template. Why not? Because every time you add or remove a blog from the list, you'll either have to republish your entire site, or have it only show up on new posts. Fortunately, for PHP powered sites (as well as other dynamic sites--I'll be discussing PHP, but the same principles can be applied to other systems) there's an easy way to work around this.

The first step is to change the name of your blog files. If you have links to pages in your blog whose names end with ".html", you'll need to update them to point to the changes filenames once this is done, so don't begin unless you're ready to follow through. To change the filename, log in to Blogger, select your blog, click the Settings tab, click Publishing in the submenu, and change your blog filename extension to ".php" (or whatever extension is appropriate for your server). Next, click the Archiving submenu, and do the same with your archive filename. Now that you've done that, you can put PHP code into your blog template, and it will be executed when people load your blog pages.

But before you modify your template, there's another file to set up. First, create a PHP file named blogrollinc.php like this:

<?php
$feedlist=array(
/* 0 */ array('Info Bite','http://www.geckotribe.com/ibl/b/'),
/* 1 */ array('Mental Arc','http://antone.geckotribe.com/mentalarc/'),
/* 2 */ array('The Busted World','http://antone.geckotribe.com/bustedworld/'),
/* 3 */ array('SPAMless','http://SPAMbaffle.com/spamless/'),
/* 4 */ array('The Divined Comedy','http://antone.geckotribe.com/divined_comedy/'),
/* 5 */ array('The Single Life','http://LDSSinglesNetwork.com/the-single-life/'),
/* 6 */ array('Extreme Website Makeover','http://css.geckotribe.com/extreme/'),

Reader Comment:
Mr Splosh said:
Thanks! thats really good, can you do an archive improver, so we can categorise in other ways, rather than just date?
(join the conversation below)

/* 7 */ array('ongoing','http://www.tbray.org/ongoing/'),
/* 8 */ array('Sam Ruby','http://www.intertwingly.net/blog/'),
/* 9 */ array('Contentious Weblog','http://blog.contentious.com/'),
/* 10 */ array('mezzoblue','http://www.mezzoblue.com/'),
/* 11 */ array('Jeffrey Zeldman - Daily Report','http://www.zeldman.com/'),
/* 12 */ array('The Man in Blue','http://www.themaninblue.com/'),

/* 13 */ array('Living LDS','http://livinglds.com/'),
/* 14 */ array("This Christian's Journey",'http://antone.geckotribe.com/christian/'),
/* 15 */ array("A Daily Scripture",'http://antone.geckotribe.com/scripture/')
);
$feedlists=array(
'infobite'=>array(7,8,9,6,1,3,2),
'spamless'=>array(6,0,1,2,4),
'extreme'=>array(10,11,12,0,3,9,7),
'mentalarc'=>array(6,0,3,2,4),
'busted'=>array(1,3,6,0,4),
'divined'=>array(2,1,3,6,0),
'scripture'=>array(14,5,13)
);
function ShowBlogRoll($blog) {
global $feedlists,$feedlist;
if (isset($feedlists[$blog])) {
foreach ($feedlists[$blog] as $key=>$val)
echo '<li><a href="'.$feedlist[$val][1].'">'.$feedlist[$val][0]."</a></li>\n";
}
}
?>

Change the values in $feedlist to the names and URLs of the blogs you want in your blogroll (or blogrolls, if you have multiple blogs). Below that, $feedlists is a list of your blogs where you can select a different set of blogs to include in each blogroll, and can set the order in which they will appear. If, for example, you have a blog about your family, one about web design, and one about fly fishing, you're likely to want a different blogroll on each. Once you've finished editing, upload this file to your webserver.

Now for your blog template: in the place where you want the blogroll to appear, insert something like this:

<h6>Blogroll</h6>
<ul>
<?php
include '/home/yourusername/htdocs/blogrollinc.php';
ShowBlogRoll('extreme');
?>
</ul>

Adjust the path to blogrollinc.php as needed, and in the call to ShowBlogRoll, pass in the key name from $feedlists for the blogs you want to list. Then update your template, publish, and check it out.

Any time you want to update one of your blogrolls, just update blogrollinc.php. No need to republish your blog--the changes will appear immediately.