0

I have a website which currently resides in the form of HTML files in my server's folder. I have some elements that are present on each page, and have to be the same, e.g. the navbar. When I add a new link to the navbar, if I want to make that effective for every page, I have to go around every single file replacing code. Is there a way to make the code be "inserted" from a file? I know something like that is possible with <?php include() ?>, but how would I be able to do that without server-side scripting?

EDIT: jQuery and other libraries are fine.

Bluefire
  • 11,339
  • 21
  • 61
  • 102

5 Answers5

0

I don't know if this is too much for your use case, but there is the handlebars.js library available for Javascript and HTML templating. Of course you would need to program Javascript then.

j0nes
  • 7,800
  • 3
  • 34
  • 40
0

Form what I undarstand you are in need for a JS templating engine of sorts :

http://handlebarsjs.com/

is what might fit your needs

Nikola Sivkov
  • 2,779
  • 3
  • 31
  • 63
0

You should be able to do

<!--#include virtual="path/file.html" -->

also, see How to include an HTML page into another HTML page without frame/iframe?

Community
  • 1
  • 1
slapthelownote
  • 4,069
  • 1
  • 21
  • 27
0

Of course that is possible. For example with jQuery. See the .load() function here.

Andreas
  • 492
  • 5
  • 16
0

The only way to go without the server-side is javascript. See Aviatrix's post for a JS template.

In your case, and only if server-side IS ACCEPTABLE for you, I would rather go for a more generic approach; instead of having your navbar in each file/page, create your navbar one time in a separate file, and use it in every page (php or other ssi approach is needed).

leMoisela
  • 996
  • 7
  • 17