Reputation: 2573
I'd like to know the best way to 'get' the index .nav
and .footer
and other elements that always stay on the page and then copy them to my subpages.
I'm trying to avoid copying and pasting these elements into the HTML subpages.
Upvotes: 0
Views: 261
Reputation: 35409
ASP.Net use MasterPage
s:
http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx
PHP use include
s:
http://php.net/manual/en/function.include.php
Or you can jQuery.load()
the sections of a template.html
into each page:
Upvotes: 1
Reputation: 17061
You can use jQuery'a load()
function.
You can put this on any page you want the nav or footer to duplicate to:
$("#nav") // select nav element on current page
.load("index.html #nav > *"); // grab contents of nav from index page
Of course, the best way will still be to either put the nav in a file alone and use PHP to include it on the page or just copy and paste them, in case you have a smaller site.
Upvotes: 0
Reputation: 60413
Use a server side language (PHP, Ruby, etc.) and split them out into "includes".
Or alternatively use some kind of build systme that allows you to "include" snippets and then compile the files to completed html pages before publishing. Adobe Dreamweaver's Templates and Library features are an example of this, but you could do it with open source tools like Rake, Phing and Ant as well.
Upvotes: 1