Looking for an alternative to PHP for including your website layout on your pages? Try using server side includes.
If your website is hosted on a server that does not allow you to use PHP, then you may think there are only a few other ways to include your layout on all your sites pages. You may jump directly to using iFrames, which I am highly against. There is a better way of including your layout and most web servers support this method. It also makes your site SEO friendly as well, making it rank higher on google searches. You can check with your web host to see if your server supports server side includes.
Your full layout code should look similar to this:
<html>
<head>
<title>Integrate Your Website Layout With Server Side Includes - IceCaves.net Webmasters</title>
<meta name="description" content="Looking for an alternative to PHP for including your website layout on your pages? Try using server side includes.">
<meta name="keywords" content="webmaster,script,php,javascript,css,html,article,tutorial">
<style type="text/css">
body {
text-align:center;
color:#000;
background:#fff;
}
</style>
</head>
<body>
<div align="center">
<h1>IceCaves.net</h1>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left">link<br>link<br>link<br>link<br>link</td>
<td align="center">PAGE CONTENT GOES HERE</td>
</tr>
</table>
<i>Layout, Content, & Coding © 2006-2011 IceCaves.net</i>
</div>
</body>
</html>You will need to divide the layout into two parts:
- Code Before Page Content
- Code After Page Content
Now your layout code should look like this:
Before Page Content
<html>
<head>
<title>Integrate Your Website Layout With Server Side Includes - IceCaves.net Webmasters</title>
<meta name="description" content="Looking for an alternative to PHP for including your website layout on your pages? Try using server side includes.">
<meta name="keywords" content="webmaster,script,php,javascript,css,html,article,tutorial">
<style type="text/css">
body {
text-align:center;
color:#000;
background:#fff;
}
</style>
</head>
<body>
<div align="center">
<h1>IceCaves.net</h1>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left">link<br>link<br>link<br>link<br>link</td>
<td align="center">After Page Content
</td>
</tr>
</table>
<i>Layout, Content, & Coding © 2006-2011 IceCaves.net</i>
</div>
</body>
</html>Now that you have divided your layout create a file in your home directory called top.txt. In that file put the first part of the layout code. Next, create another new file in your home directory called bottom.txt and put the second part of the layout code in that file.
Every page of your site must have the extension .shtml. Now put the following code on your sites pages:
<!--#include virtual="/top.txt" -->
CONTENT HERE
<!--#include virtual="/bottom.txt" -->Replace CONTENT HERE with the content for your page. Now save and upload the file. The page works just like a PHP page without the use of iFrames!
There are many other cool tricks you can do with server side includes! That will be in a future blog.
Thanks for reading. If you have any questions or comments please post them below.
