November 16, 2007

Modular Design

An important factor to consider when designing a family of websites for your Internet business, is the ease of maintenance. You should always make your websites modular, so that you can make across-site changes by changing one file.

What is the best way to do that? Break the page down into sections, and put each in a separate file. You can use SSI includes, or PHP. If you don’t know PHP you really don’t need to learn much about it to use this technique. In fact, I’ll explain it all here.

This assumes you are using a hosting service that includes PHP, which they almost all do automatically. Now, if you want to use the .htm or .html suffix for your web pages, you need to have SSI turned on so you can use includes:
<!–#include virtual=”myfile.php” –>

Or you can add one line to your .htaccess file if you are using a Linux server:
AddType application/x-httpd-php .htm .html

Or you can just name your file with a .php extension, and then your includes will work without any further modification.

Now, suppose one section of your page that repeats is the footer. You put the footer HTML code in a file and save it as footer.php — then you can include it with:
<?php include(”footer.php”);?>

Or, if you have SSI turned on:
<!–#include virtual=”footer.php” –>

Either way, you will need to include the relative path if the file is not in the same directory as your HTML page.

Things get a little more complicated when you want to put the header section of your page in its own module. The header usually includes your keywords, page title, and other meta tags that change from page to page. There are two solutions to this problem.

The easiest approach is to put the variables in a database, then look up their values in the include file, and assign them to variables. Variable can be inserted in your HTML just like the include file itself was:
<title><?php echo($title);?></title>

A less satisfactory solution is to have a variable assignment file for each HTML file, that initializes those values that change from page to page. Changing these is just as much trouble as changing each HTML file on its own — but if you want to change other parts of your header, you still benefit from having separate modules. You can have the include file detect the correct variable file by giving it the same name as the HTML page it applies to, but with a different suffix. So you might use .inc files, for example. This bit of PHP code included in your header.php file will find the correct .inc file to match the .htm or .php file it is included in (assuming .htm as the suffix on the main HTML file):

<?php
$file=basename($_SERVER[’PHP_SELF’],’.htm’);
include($file.’.inc’);
?>

If you put the main content for your page in another include file, and use a consistent prefix and suffix, the same method will find the correct file, so long as it is in the same directory as the main HTML file:

<?php
$file=basename($_SERVER[’PHP_SELF’],’.htm’);
include(’x’.$file.’.php’);
?>

You can use anything you like in place of ‘x’.

To avoid getting annoying error messages that might reveal details of your page structure to hackers, your initial header file should include this code to turn off PHP errors:

<?php error_reporting(0);?>

That the number 0, not the letter O inside the parenthesis. When trouble-shooting your pages, looking for problems, you will want to replace the above line with:

<?php error_reporting(E_ALL);?>

Whatever scheme you use to modularize your websites, be consistent from one site to the next, and you will find it much easier to maintain your Web Empire. Being consistent in method does NOT mean having the same page design elements, links, file structure, etc.,  for your Internet business sites, as we will see in our next post on the hitherto unmentioned Duplicate Layout Penalty.

November 15, 2007

Multiple Websites

Why have more than one website for your Internet business? Well, there are several advantages, even if you have only a single product or service. The more different streams of income you have, the more advantageous the multiple-website strategy becomes.

Consider the simplest case first. Suppose I just sell widgets. Surely, my widget site has everything anyone needs to know about my widgets and how to buy them. Why would I need any other sites? Well first, if your single site doesn’t come up #1 in the search engines for the term ‘widget’ you are probably missing sales. Multiple sites help you achieve that #1 spot — and if you really work at, perhaps you can get #2 and #3 spots with your other widget sites.

Of course it does nobody any good if you just copy the information from your existing site to a new one. That is duplicate content, and it won’t show in the search results at all. What you need is another site that compares the different types of widgets. And another site on the history of widgets. And another site with pictures of the all the different types of widgets ever made. Etc., etc.

Some people try to put all that on one website, thinking they will then have the best widget website, so everyone will find it when looking for widgets. And to some extent, that works. But once on your site, what do people do? Oh look at the interesting widget history. Ah, I never thought there were so many types of widgets. And look at these pretty widget pictures … They get distracted by all the information and never get around to actually buying your widgets.

On the other hand, suppose you have multiple widget sites. Only people already interested in the history of widgets will go to your widget-history site, and there they find your sales site recommended for when they want to actually buy widgets. The same for each of your other sub-topic sites — they all funnel traffic (and web-link ‘credit’ for search engine ranking) into your sales site. Your sales site does not link back to your sub-topic sites. When someone finds your sales site, all they should see is information relevant to making the sale — no distractions!

Now suppose you have multiple streams of income — selling advertising space, affiliate links, your own products. A network of sites provides more ‘property’ for placing ads and affiliate links, while still funneling those persons interested in buying your product to your sales site or sites (one site per product usually works best, unless you have a product-line of related items).

In future posts we will look at how you produce, manage and optimize multiple web sites, so that your Internet business grows into your own Web Empire.