views:

159

answers:

3

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?

+4  A: 

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

OMG Ponies
+1  A: 

To share common HTML snippets between pages, you'll need some sort of server-side "code".
The simplest thing you could do that I know if would be Server Side Includes, "SSI"

see: http://httpd.apache.org/docs/1.3/howto/ssi.html#includingastandardfooter

James Maroney
+1  A: 

There are basically two options: frames (or iframes) or javascript. Frames come with a whole host of problems and I really don't recommend you go down this route. Have a look at PURE javascript library for clean and simple client-side templating.

Ramon
Server Side Includes is a 3rd option. Javascript is not ideal - you can't guarantee it will be enabled in the browser.
OMG Ponies
Well, just in case he really needs a client-side solution, the option is there.
Ramon