Search code examples
htmlcode-reuse

Html reuse without code


I am creating some static html pages outside a .net and outside a ruby-on-rails environment.

I created a menu I want to share between several pages, but I'm wondering how this is done using regular html constructs (i.e. without .net's master pages and without rail's layouts)

Is there a way to do this without cutting and pasting?


Solution

  • What web server are you using? It's likely you'll have to enable Server Side Includes in order to use:

    1. Save the HTML for the common elements of your site as separate files. For example, your navigation section might be saved as navigation.html or navigation.ssi.
    2. Use the following SSI tag to include that HTML in each page.

        <!--#include virtual="path to file/include-file.html" -->
      
    3. Use that same code on every page that you want to include the file.

    Reference: http://webdesign.about.com/od/ssi/a/aa052002a.htm