Search code examples
htmlserver-side-includes

HTML Include file


I have a basic web application packaged as an EAR deployed on GlassFish. The web module has some html files. The html files have a common footer, an html file, that I would like to extract out and make an include. When I do, and put:

<!--#include virtual="insertthisfile.html" -->

in an html file, it does not work. Should this work?


Solution

  • This is a technique called Server-Side Includes (SSI). It may not be enabled on your web host. If it is, sometimes they force a .shtml extension to be required for included files, so try renaming your file insertthisfile.shtml.

    If that doesn't work, you might be able to enable SSIs in a .htaccess file (assuming your web server is Apache). You can find instructions on how to do this by googling. There's a decent set here.

    If that fails, I would contact your web host and see if they have SSIs enabled.