A Beginners Guide to Server Side Includes

Server Side IncludesBeginner? That's OK!

Whilemuch has been written about Server Side Includes (SSIs -also known asVirtual Includes) much of this information is designed for intermediateto advanced webmasters. This article is aimed at beginners. It isassumed that the reader has no prior knowledge of scripting languages,servers, or any other advanced computer skills. This article willintroduce the reader to SSIs and explain how they are used in web sitedevelopment. SSIs are guaranteed to save you time as your web sitedevelops and changes over time.

Servers: just a place for your stuff?

Itis important to understand that all the code for your website is storedremotely on a computer called a server. On a very basic level, theserver (remote computer) is just a place where you can store the fileson the "net." These files would typically contain your web site's HTMLcode and possibly some files containing pictures or graphics.
Forexample, a very simple web site might consist of 5 web pages with fivecorresponding files that are stored on the server. One file is named index.html and we will have four additional files. These files might be named about-me.html , education.html , resume.html , and portfolio.html. We'll say that this simple 5 page web site is run by a freelancer who uses this site as a kind of virtual advertisement.

Servers Part 2: more than storage?

Wehave established that the server functions as a storage place for ourfiles, but it is important to recognize servers can also do things.Similar to the operating systems software on our personal computers,servers have software that allows them to access and organize files.Servers can also carry out more advanced functions. Take, for example,what the server does when someone visits the root directory of yoursite; the server automatically loads your index page (e.g., index.html,index.php, index.asp). This is a very simple example of something thathappens on the "server side."

Why do I need includes?

Nowthat we understand that remote servers have software on them capable ofcarrying out certain tasks, we can turn our attention to the "includes"portion of the equation. What are includes? Let's take our hypotheticalweb site that serves as an advertisement for our imaginary freelancer.Imagine that the freelancer designs a left hand navigation menu so thatpeople can easily browse all five pages of his site. Therefore, eachpage of this site contains the code for the navigation bar. Imaginethat a few months after launching this web site, our freelancer wantsto add a Frequently Asked Questions page. Our freelancer now has toupdate the navigation bar code in each of his five existing pages. Nowthere are six pages with this same navigation bar code. A month laterour freelancer wants to add a self-written article to his site. Onceagain every page on the site needs to be updated. Imagine having a sitewith 100's of pages. Do you want to manually update 100's of pages ofcode? These are the types of situations where virtual includes can saveyou hours of time.

What are we including on the server side?

Perhapsit would be better to think of includes as "modules" that we can insertinto our web pages. These modules (or "includes") are usually just textfiles that contain HTML code (although they can be other file formats).The code inside these files can be inserted anywhere in a page simplyby using an include command. For example, imagine for a moment that ourfreelancer had the foresight to realize that the navigation menu wouldchange at some point in the future. Instead of putting the code for thenavigation menu into each individual page, the freelancer placed thiscode into a separate file. For the sake of example, we can call thisfile nav-menu.html Our freelancer can now simply place an "include" command that refers to the nav-menu.htmlanywhere he/she wants to place this menu. The advantage of this isbecomes apparent when our freelancer needs to modify the navigationmenu. Just one file needs to be edited, nav-menu.html, and allthe pages containing "include" refering to this file will automaticallyupdate themselves. This time savings is the primary advantage of usingincludes.

OK, I get it, but what does an include look like?

Eventhough this is not a "technical" article, many of you are probablywondering what an "include" looks like. Therefore, one example for PHPis included below. Please note PHP is just one type of scriptinglanguage that can be used, depending on what your server is running. Inthis example, the code contained in the file "nav-menu.html" will beinserted into any web page where the following code is placed:




Keepin mind that, for technical reasons, server side includes will never bevisible when you view the source code for a page in your browser. Thisis because the include happens on the server (before presenting theresulting code to the browser). This makes the use of SSIs invisible tobrowsers, bots, spiders (which is why they are search engine friendly)

Summary

Thecatch-22 of server side includes is that the need for them only becomesapparent when faced with the task of updating tens or hundreds of pagesof code. There are many resources on the web that will instruct you howuse virtual includes, and procedures will vary depending on the type ofscripting language supported by your server (e.g., ASP, PHP). Hopefullyyou now understand Server Side Includes and how they can benefit thewebmaster.

Related Articles

  • Server Side Includes
    This very helpful tutorial makes it much easier to make changes throughout your entire website. It is easy to follow and has plenty of code.
  • ASP : Server Side Includes
    This tutorial was written by one of the great guys at HTMLForums. I read through this tutorial myself and found it to be very useful and easy to understand.
  • Use Server Side Includes To Ease Your Workload
    Im all for making things as easy as possible. The whole idea in business, and life, is to work smarter not harder. When designing websites, I not only want to create them with as little effort as possible, but I also want to make maintaining them easy.
  • Web Hosting - The Essential Guide For Beginners
    Web hosting is a seemingly complex topic that small business owners can sometimes feel confounded by. When the techie on a message board offhandedly mentions IP addresses, domain names, and the type of hosting plan your business needs, you might be ready to head for the hills!
  • Using SSI's To Ease Site Maintenance
    Before building a site, every webmaster has to make a decision on what layout method to use. Most seem to go with either a frame or a table-based layout, the latter being more popular in these days. While both of these have their advantages and disadvantages, a frame-based site is usually easier ...
  • PHP : Beginners Guide PT.1
    What does PHP stand for?
    PHP stands for Hypertext Preprocessor and is used for background programming for web sites.
  • The Power of Windows Hosting - Save Time and Money
    The Windows Server environment will give you far more freedom and flexibility to run a wide range of web applications and allow you to get a dynamic web site up and running fast.
  • How To Easily Create A Search-Engine Friendly Navigation Menu For Your Website
    A navigation menu is an important element of a website. A good navigation menu helps your visitors navigate through your website efficiently - in as few mouse-clicks as possible.
  • Update Your Site Instantly With SSI
    There are probably two main ways you currently update your site. The first, and most important, is adding new content. Whether you are updating a calendar, adding a new page, or putting in a photo of a new product, you are enhancing the value of your site for your visitors. The second, and more t...
  • A Web Hosting Guide for Beginners
    Besides a qualitative web design and unique content your hosting choice might be decisive, so read these tips to be able make a wholistic approach to a site building process.

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.