bharatbhasha.net


Free Articles  >>  Computers and internet >>  Page 749  >> 

SSI Why and How to Use Server Side Includes



SSI: Why and How to Use Server Side Includes
 by: David Leonhardt

If you are a webmaster or a website owner and have not yet used server side includes (SSI), I am about to make your life soooo much easier. SSI can save you a lot of time updating your site. Set them up right at the beginning and you will be forever grateful that somebody thought up SSI.

In this article we will look at what SSI is, why it makes life so easy, and exactly how to set up SSI on your website...and then I'll share two little bonus tricks I've discovered.

What is SSI?

SSI actually covers a number of features to improve your website. I am going to speak here of just one critical improvement, referred to as an "include" file.

Essentially, an "include" file is a separate file that your web page can include as if it was part of the page file. Let's take a real-life example. My site at <a href="http://www.vitamin-supplements-store.net" target=new>http://www.vitamin-supplements-store.net</a> uses SSI in a number of places.

If you are used to using FrontPage or have recently learned HTML, you probably assume that every web page is a single html file. The example above is actually five files. There is the main HTML file for the page. There is a style sheet (CSS) and there are three SSI "include" files -- one for the left navigation menu and two for the two navigation menus across the bottom. I could have, perhaps even should have, used more "include" files, but you can be the judge when you've finished reading this article.

Why use SSI?

SSI makes it easy to bring changes to your website. There are some changes you will need to make to every page or to every page in a specific section. Your website might start out with just 10 pages, and you might figure that it is no big deal to cut-and-paste a change to the navigation menu 10 times.

But each time you add a page, you have to update that menu. And with each new page added, you have to paste one more time. When you reach 50 pages (Never thought your website would grow that big? You're not alone.) it becomes very tedious to update.

For instance, when I wanted to add the website monitoring logo and the link to the navigation menu at <a href="http://www.thehappyguy.com" target=new>http://www.thehappyguy.com</a>, I had to change just one file, and -- presto! -- the change appeared on every page of the site bearing that navigation menu. It was so very much easier than past updates before I began using SSI.

There are two other benefits to SSI "include" files. Because a single line of code replaces what might have been several dozen in each HTML file, your files are much smaller, taking less space on your server. And, because the "include" file has already been loaded with the first page a visitor sees, the next page is much quicker for visitors to load.

How to set up SSI?

You need three things to set up SSI.
  1. Configure your server for SSI
  2. Set up your "include" file
  3. Call up your "include" file into your web page HTML file


First, you need your server configured for SSI. Ask your web host if this has already been done. Also ask if it has been set up to parse .html extensions to read SSI.

If your server has been set up for SSI, you are one step closer. If it has also been set up to parse .html extensions to read SSI, you are two steps closer.

Not all hosts support SSI, but most do. If yours does, but it has not been set up for your account, look for the .htaccess file in your root directory (where your index.html or home page file is stored). In my experience, this is not usually viewable using an FTP process; you have to find it through your control panel.

The .htaccess file is a text file. If you do not already have an .htaccess file on your server, you can create one in NotePad or even in Word (just save it with a .txt extension), but whatever you do, make sure not to write over a .htaccess file already on your server. If it is already there, just add the following lines to the file, being careful not to erase anything that is already there: <dir>

AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes </dir>

So far, so good. But this will recognize only .shtml files for includes, and you probably don't want to change the .html extensions to .shtml on all your pages, if for no other reason because it will mess up all your inbound links to those pages.

So add this line. In theory, it should be the second line, but careless me has gotten it to work at the end, too:

AddHandler server-parsed .html

Save the edited .htaccess file to the root directory of your server.

As an aside, there are several ways to configure your server for SSI. This one has worked for me across several hosts.

So much for the techie stuff, now you need the second element: the "include" file itself. Suppose your "include" file is the navigation menu. You don't need "head" and "title" and "body" tags. Just type in your text and code just the way it would appear in your webpage. It's that simple. Save it as an HTML file, and load it to your route directory or to its own directory.

All you need now, is to call up your navigation menu in each file you want it to appear in. To do this, a simple line suffices where a whole column of code and text once stood.

Here is the line to place in your code:

This assumes that nav1.html is the name of the "include" file and that it is in the same directory as the page it is being inserted into. If you place the file into a directory called "nav", you would have to include code like this in your web page file:

That's all you really need to know. But here are a couple bonus tricks that will make SSI "includes" work even better for you.

Bonus Tip #1

You don't need to stuff everything into a single SSI file. What if some elements you want on some pages and others not? Let me offer two examples of situations that call for splitting the SSI "include" file in two.

The first is on my vitamin site. Return to <a href="http://www.vitamin-supplements-store.net" target=new>http://www.vitamin-supplements-store.net</a> and look at the links across the bottom. The first row is typical website stuff: contact, privacy, etc., which one wants access to from every page of the site. The second is the links directory, which a webmaster does not typically want linked from every page. For example, see the bottom of my humor article at <a href="http://www.vitamin-supplements-store.net/articles/eggs.html" target=new>http://www.vitamin-supplements-store.net/articles/eggs.html</a>. The row of links directory is not there.

The second example is this article on search engine tips: <a href="http://www.thehappyguy.com/SEO-tips.html" target=new>http://www.thehappyguy.com/SEO-tips.html</a>. Notice again that there are two different navigation consoles. The first is generic to the site, the second is specific to that section of the site. So a second SSI "include" file, using just one additional line of code, can provide interlinking for the section, without affecting other sections of the website. This is very handy for large sites.

Bonus Tip #2

You can also use an SSI "include" file to hide some of your source code. I will show you a ridiculously simple way to do this.

There are at least two legitimate reasons why somebody might want to hide parts of their code. The most obvious would be if you are running a proprietary script. The second is if you are running a script that displays content, but shows up as a script in the source code. This was my challenge.

At the bottom of the navigation menu at <a href="http://www.thehappyguy.com/self-actualization-articles.html" target=new>http://www.thehappyguy.com/self-actualization-articles.html</a>, there is a "Happiness Quote of the Day". In fact, it is a random quote that reloads when the page reloads. I had included the random-text script in the SSI "include" file, but the search engines were seeing the script in the source code, not the text that human visitors were seeing. So I placed the script in its own "include" file, which I inserted like this into the main "include" file:

Now the search engines see the same things as humans see. Why would I care? Search engines visit more frequently pages that change more frequently. That does not mean the site will rank higher, unless frequent change is part of the search engine's ranking algorithm, but it does mean that other changes will be indexed faster.

To sum up, SSI "includes" can save you time and headaches when changes need to be made to your site, plus they reduce the file size and increase the loading time of your pages. Once you've set up the server to read SSI, all you need to do is create an "include" file and call it up in your web page using one line of code.

I can hardly believe I wasted so much time cutting and pasting before I learned about SSI. You won't believe it either!


About Author David Leonhardt :



David Leonhardt is a freelance writer, and an online and offline publicity specialist. Contact him at: mailto:info@thehappyguy.com
For a copy of Don't Get Banned By The Search Engines:
http://www.thehappyguy.com/SEO.html
For a copy of Get In The News:
http://thehappyguy.com/publicity-self-promotion-report.html .
To promote your website with an ezine:
http://www.thehappyguy.com/ezines.html
Info@thehappyguy.com <input type=hidden name="sf1" value="The_Author">


Article Source: http://www.bharatbhasha.net
Article Url: http://www.bharatbhasha.net/internet-and-computers.php/1313

LD
Other Articles by David Leonhardt

10 Things You Should Be Monitoring On Your Website
 by: David Leonhardt Every business needs to know how it is doing. That's the idea behind exit surveys, customer feedback forms, suggestion boxes and other devices. Without feedback from the customer, monitoring inventory, expenses, revenue and other benchmarks, a business can take a quick slide down a slippery slope, without the owner ever seeing it coming – or being able to stop the slide. Webmasters also have things they should be monitoring on their websites. Most of these can be...

Network Monitoring for Serious eCommerce
   by David LeonhardtBy David LeonhardtIn the real world, businesses come in every size, from self-employed entrepreneurs like me to mega malls like Wal-Mart.On the Internet, companies come in every size, too, from a stand-alone ebook sales page with webmaster and owner all in one, to 300 pound gorilla like Amazon, with over a million pages requiring the entire population of a small country to serve as webmaster.If your site is a single page, it is its own network. But if your site is any...

Choosing a Web Host Based On Price Don t
Choosing a Web Host Based On Price? Don't!  by: David Leonhardt It's tempting. There are so many companies offering cut-rate hosting – loaded with astounding post-futuristic techno-gizmo features ! – that it just makes sense to save a few dollars, right? Think again. First, consider how much you would be saving. If you run a business site, saving $5, $10 or even $15 a month is not a big saving. No going concern will become a stopping concern on account of even $15 a month. But the wrong...

Customers Don t Always Connect Where They Live
 by: David Leonhardt Pop Quiz: You have an international website and you want to do business in Canada. But you want to make sure your website delivers top performance to your Canadian customers: speed, accessibility, as well as proper functioning of digital certificates, forms, password protections, shopping carts and more. In which of the following cities would want a website monitoring station? Toronto, Canada's metropolis Montreal, Canada's second largest city Vancouver,...

Web Site Monitoring Is A Global Necessity
 by: David Leonhardt Bill Huang sits down at his computer. As he connects to the Internet, he glances out at the sun poking its nose above the Hong Kong skyline. It will be another busy day, and he has to order those slippers for his wife before rushing off to a meeting. He types in his search terms and Google faithfully reports: Results 1 - 100 of about 1,760,000. Search took 0.34 seconds. Bill clicks on a the Big Soft Slipper web site and waits for the page to load. Site unavailable,...

How Website Monitoring Saved an Auto Parts Retailer
CASE STUDY: Website Monitoring Saves Auto Parts Retailer PROBLEM: Customers complaining about site outages and slow site response times. Hosting company claiming that the problems had been resolved. Customers remaining dissatisfied. METHODOLOGY: External website monitoring on a page-by-page basis at one-minute intervals pinpointed the problems. SOLUTIONS: Realigning shared hosting, fixing database indexing, DNS server upgrade, altering the web host's BGP configuration and regular...

I Saw An Angel At Work
 by: David Leonhardt Sometimes you have to see something to believe it. Like angels. Unfortunately, angels are adept at not being seen, yet many people believe in them. I saw an angel at work last year. No, I did not see the halo. Or the feathered wings. Or a flowing white gown dancing in the wind. But there was no mistaking the unique handiwork. When Little Lady was just one-and-a-half years old, we were visiting friends in another town. Sunday morning, we accompanied them to...

Curbing the Public Nuisance Part 1
Curbing the Public Nuisance (Part 1)  by: David Leonhardt He's been around since the dawn of humanity. His profession is even older than the world's oldest profession. He's been loathed and reviled by politicians, bureaucrats and hot dog vendors. I am speaking, of course, of the public nuisance. He was that slithery dude in the Garden of Eden, taunting folks to shoplift. Go on. Take a bite of the apple. The grocer will never know it's misssssing. Even in caveman days, the public...

Muscle Pain And Children Do Not Mix
 by: David Leonhardt I am in pain. I've been in pain all day. Last night, I was in searing pain, which is pain multiplied by pain, divided by relief, then multiplied by pain to the tenth power. In case you are not a math whiz, that equals pain with 33 zeros after it. Two days ago, I was in pain (just regular pain, no zeros). In fact, I was in pain all week. Welcome to my humor column. Actually, pain is not really all that funny ... unless it happens to somebody else. Oh, come on....

Hotel Rooms Are Nightmares
 by: David Leonhardt Ever since I began working for that Florida vacation rentals website, I have been plagued by recurring nightmares. I am haunted at night by the spirits of hotel rooms past. There was a time when I traveled quite a bit on business. Thankfully, I don't hotels hop any more. But at night I float off to a hotel room far away in time... The day's work done, I phoned home to check up on the kids. It seems there was a shouting match going on in my absence. It sounded like...

Click here to see More Articles by David Leonhardt
Publishers / Webmasters
Tell A Friend
Leave A Comment!
Download this article in PDF
Report Article!
Search through all the articles:


234 Users Online!!
Related Articles:
Latest Articles:
 
computers and internet >> Top 50 Articles on computers and internet
Category - >
Advertising Advice Affiliate Programs Automobiles
Be Your Own Mentor Careers Communication Consumers
CopyWriting Crime Domain Names DoT com Entrepreneur Corner
Ebooks Ecommerce Education Email
Entertainment Environment Family Finance And Business
Food & Drink Gardening Health & Fitness Hobbies
Home Business Home Improvement Humour House Holds
Internet And Computers Kiddos and Teens Legal Matters Mail Order
Management Marketing Marriage MetaPhysical
Motivational MultiMedia Multi Level Marketing NewsLetters
Pets Psychology Religion Parenting
Politics Sales Science Search Engine Optimization
Site Promotion Sports Technology Travel
Web Development Web Hosting WeightLoss Women's Corner
Writing Miscellaneous Articles Real Estate Arts And Crafts
Aging


Disclaimer: The information presented and opinions expressed in the articles are those of the authors
and do not necessarily represent the views of bharatbhasha.net and/or its owners.


Copyright © AwareINDIA. All rights reserved || Privacy Policy || Terms Of Use || Author Guidelines || Free Articles
FAQs Link To Us || Submit An Article || Free Downloads|| Contact Us || Site Map  || Advertise with Us ||
Click here for Special webhosting packages for visitors of this website only!
Vastu Shastra

Linux Hosting Provided By AwareIndia