Unless you're a web programmer, learning HTML or learning how to use your HTML editor is 1 of your first tasks in order to create your first web site. Then after that first page is up and available, you start working on the second, then the third and so on until you have several pages built on your site. And because you want all your pages on your site to have the same look and feel to your site visitors you hopefully have created a page template.
Then, after you've gotten several pages up, you decide you need to add or change something. Maybe it's the copyright information, the contact information, a new menu link, etc. but whatever it is, it's something that appears on every or almost every page of your site.
It's at this point when you are faced with going in and modifying many pages on your site that you will become painfully aware that you really should have learned just a little about Server Side Includes (SSI) before you started.
What are Server Side Includes and why do you need to know about them?
Server Side Includes allow your web host to perform copy and paste actions on your web pages as the page is being loaded in the site visitor's browser. In other words, as your page is being loaded, your web host reads the code for your page, gets the instruction to find another file and include it on the page, follows the instructions, finds the file and merges it onto your page before showing your page in the visitor's browser.
Why do you care about Server Side Includes? Because they make it extremely quick and easy to change things that are common on many pages of your site. Instead of going into every page that has your navigation menu to add or change a link, you simply change 1 file and that change appears on every page! And, if used properly, Server Side Includes can help make your pages more responsive.
Now before you run off because you think you're not ready for doing complicated "techie" web programming, let me tell you that the hardest part of using Server Side Includes is ... drum roll please ...
You need to make sure your web host allows the use of Server Side Includes.
Because Server Side Includes have been around for a long time and because using them has become more popular, most web hosts do support them. However, Server Side Includes are a Linux/Apache specific feature, so if you're on a Windows server you'll need to find a Windows equivalent of SSI. (Sorry, I can't help you with that one.)
There are 2 ways to find out if your web host supports Server Side Includes:
Ask them.
Perform a simple test.
Insert this line of code
<!--#echo var="DATE_LOCAL" -->
into 1 of your web pages and rename the file, "test.shtml"
Upload the file to your server.
Display the file in your browser.
If you see the current date where you inserted that line of code, your host supports Server Side Includes.
Using Server Side Includes is just as easy as performing the above test and the only hard part is remembering to use the ".shtml" extension for your web pages.
You can use Server Side Includes to include just about every file type like; html, htm, php, jpg, gif, txt, etc. I actually use text files without the ".txt" extension for most of mine because that's how I first learned to do it. I also usually put the file to be included in the same directory as the pages that include it for the same reason. However, you are not restricted to either of those things.
So how do you get your host to paste 1 of your files into your web pages?
If you're a beginner, here are 5 easy step:
Create or open your web page in your HTML editor.
Select the section of your page that you want to appear on other pages.
Copy the HTML code for that section and paste it into another file. (I usually use Notepad and create a text file without the ".txt" extension) Name and save your new file.
In your web page file, replace all the code you just copied and pasted with the following:
Put your file's name in place of "xxxxx". And if the file is in a different directory than your web page be sure to include the full path to the file starting from your root directory.Upload your files and check them out.
Just like many other web programming techniques, there are other ways to use and write Server Side Includes. Also, it isn't necessary to use the ".shtml" extension for your web pages if you know how to modify the code in your .htaccess file. But if you're a beginner and just getting started, using the above directions will get you started and may save you a lot of time in the future when you want to make modifications to you site.
To Your Success,
Susan
P.S. If you found this tip helpful or have more information you would like to share, please feel free to leave a comment.
Tags: server side include, ssi, web site design, make changes to web site, shtml, navigation menu
|