We use cookies for keeping user sessions alive and for site usage statistics.
Please accept cookies to continue browsing the site.

 

(You can decline cookies later navigating to page 'Privacy Policy'.)

Get SSI running on IIS


Server Side Includes (SSI) are an optional feature of the web servers helping the developers to include HTML file content from a base file into multiple other HTML files with a single line of code. We need this if we are creating a simple, elegant and fast pure HTML site, without active server computing, just invoking content delivery capabilities of the server.

There are 3 major steps required to get SSI running on IIS 7 and later:

  • Configure IIS roles,
  • Extend IIS handlers,
  • Invoke a SSI call in you HTML code.

[1] To configure required IIS role features go to your 'Server Manager' (on a server machine) or 'Programs and Features' > 'Turn Windows features on or off' (on a common desktop machine). Find the IIS group and check 'CGI' and 'Server-Side Includes' to enable required features.

[2] Now the web server is SSI-enabled, but this will work only for the default file types with .stm, .shtm or .shtml extension. You will probably not like it, not willing your site visitors to browse to such weird file types.

To enable SSI for the well known .htm and .html files open 'IIS Manager', select you site, find and open 'Handler Mappings' feature and create module mapping entries, separately for .htm and .html, optionally restricting availability for only 'File or folder' requests:

[3] Above actions complete the setup. Now create a file like e.g. 'menu.ssi' (The .ssi extension is optional, but should be considered good practice). Put in this file only the partial html code for the menu, no , or like tags, e.g:

<ul class="menu">
    <li><a id="miHome" href="Default.htm"> Home</a></li>
    <li><a id="miPage1" href="page1.htm"> Page 1</a></li>
    <li><a id="miPage2" href="page2.htm"> Page 2</a></li>
    <li><a id="miPage3" href="page3.htm"> Page 3</a></li>
</ul>
Call the .ssi content from within your other html files using one of following options, depending on how you menu.ssi file is deployed on the server:
<body>
  <!-- ... -->
  
  <!--#include virtual="/includes/menu.ssi" -->
  <!-- or -->
  <!--#include file="menu.ssi" -->

  <!-- ... -->
</body>

Style it and have fun!


Back to List