Server Side Includes - SSI Examples

The left menu (Site Navigation)  and the footer at the bottom have been inserted using server side includes. If you view the source, you will not see any of the directives to insert the includes just the actual codes for the menu and footer. The code to insert the include is:

<!--#include file="name-of-file.txt" -->

The above code ONLY WORKS if the include is located on the same level as the file it is being inserted in to.

Because I always keep my includes in a folder named  _includes, the code I have inserted to call the includes  is:

The coding for the left menu is

<!--#include virtual="_includes/new-left-menu.txt" -->

The coding for the footer is

<!--#include virtual="_includes/new-footer.txt" -->

If the page you want to insert the include is down one or two levels (folders) then you would need to add ../ for each level.

When you are working with SSI's on your computer, this is what your page will look like Screenshot of page on hard drive. Screenshot of html code for the page on your computer. When you upload your files to your freepages server, what you see is the page showing in your browser window. The include has been inserted into the page before you view it.

Additional resources:

Return to Server Side Include Tutorial