1

If all my web pages have the same navigation and footer markup, what is the best way of avoid hard-coding this in every page, so if it needs changing it's only changed in one place so as not to have to edit every html file?

Thanks

jonatec
  • 41
  • 1
  • 2

3 Answers3

1

A few options:

  • Use a static HTML generator, which will allow you to use template and pure HTML.
  • Use server side includes if your server supports them.
  • Use iframes.
  • Use any server side language, and its templating counter part (php, jinja2, django, et. al)
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
1

Use the AJAX load() method.

$('#mysection').load('yourfile.html');

Of course the URL can also point to a PHP script etc.

http://api.jquery.com/load/

Aurelio De Rosa
  • 21,856
  • 8
  • 48
  • 71
Tom Rudge
  • 3,188
  • 8
  • 52
  • 94
-1

You should use a server-side solution depending on the technology that are you using (PHP,ASP,etc...) I think you should take a look at this link.

mario595
  • 3,671
  • 7
  • 34
  • 57
  • "link only" answers are not terribly helpful. What if the link goes stale? You can improve your answer by summarizing the info in the link (leave the link in, of course). – Dan Pichelman May 22 '13 at 14:41