Skip Navigation | Groups

This site uses cookies- for more information see the Cookie Policy | Continue

 

Server Side and Design Time includes

Creating Server Side and Design Time includes


There are (basically) two types of include file: Server Side Includes (SSI) and Design Time Includes.

Server Side Includes are included with the page content when the page is served by the server, whereas design Time Includes are added to the page when the page is saved in Expression Web or FrontPage.

The main advantage of SSI is that they are added to the page by the server when the page is requested. This means that for the author, the page can be edited and uploaded to the server on its own, and all pages using the file will automatically be updated when they are requested. However, neither FrontPage nor Expression web will display Server Side Includes in pages as they are edited. SSI files must always be published to the server.

On the other hand, Design Time includes are added to the page when the Page is edited. This means that if the include file is changed all the pages using it have to be uploaded to the server. But the included segment is clearly visible in the page as the page is edited. If FrontPage extensions are not being used, the included file need not be published since it is already a part of the pages.

SSI

A file used for Server Side Include should only have the tags for the HTML being included - a typical link bar (using unordered lists) would be similar to:

<ul>
<li><a class="lk11" href="/mainpage/about.aspx">About this site</a></li>
<li><a class="lk12" href="/mainpage/sitemap.aspx">Site Map</a></li>
<li><a class="lk13" href="/feedback/">Contact</a></li>
<li><a class="lk14" href="/mainpage/privacy.aspx">Privacy</a></li>
</ul>

Note the lack of <html>, <head>, </head>, <body>, </body> and </html> tags. Everything in the file (including the BOM, if present) will be included - the presence of any of the above tags would generate invalid HTML.

A Server Side Include is added to the page using an HTML comment. The syntax is
<!-- #include virtual="/path/to/included-file.ext" --> where included-file.ext is the name and extension of the file to be included, and /path/to/ is the path to the file starting at the root folder - note the leading "/" which designates the root of the website. A virtual include always starts the path from the web root.

An alternative version is
<!-- #include file="path/to/included-file.ext" --> In this case the path is relative to the page the file is included in. If the path becomes "../path/etc" some servers will throw an error since ../ denotes a parent path, which are not allowed on some servers.

FrontPage extensions and SSI

SSI and FrontPage extensions are mutually exclusive - if one is used the other will fail. This is because an SSI has to be processed by one function of the server, whereas the FrontPage extensions are processed by a different function - and these never overlap.

Design Time Includes

A file used for Design Time includes all the tags missed from the SSI file. The HTML for the link bar above in the included file will resemble:

<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="en-gb" http-equiv="Content-Language">
<title>Website menu</title>
</head>
<body>
<ul>
<li><a class="lk11" href="/mainpage/about.aspx">About this site</a></li>
<li><a class="lk12" href="/mainpage/sitemap.aspx">Site Map</a></li>
<li><a class="lk13" href="/feedback/">Contact</a></li>
<li><a class="lk14" href="/mainpage/privacy.aspx">Privacy</a></li>
</ul>
</body>
</html>

The Design Time include is added to a page using the Insert Include FIle menu or toolbar icon - see includePage.aspx for details.

FrontPage Extensions and Design Time Includes

If the website uses FrontPage extensions, then publishing just the included file will update all the pages using it on the server. This is achieved because the publishing operation rebuilds every page on the server that use the include file - hence they are updated. In this situation, Design Time Includes also have the advantages of SSI. With FrontPage Extensions, Design Time Includes must be published to the server.