Reputation: 175
Say I want a web site with about 20 different pages. How should I go about building it so I can have the same content like a navbar and footer across all pages without having to copy and paste edits into each and every html file when something changes?
edit: I'm basically trying to figure out how to do Jade's include without installing Jade
Upvotes: 0
Views: 177
Reputation: 1461
What you're referring to is called templating and bootstrapping. There are various templating engines out there. It also depends on which server-side language you're running, as others said you maybe running PHP, NodeJS, C or something else, depends on your choice. The essential part is that you'll have separate files called templates (eg. .HTML, .EJS, .PHP, etc) for each element that repeats across different pages ( footer, header, content) and then you call that template where you want it.
Upvotes: 0
Reputation: 143
That depends entirely on how you build it. If you are using a content management system (such as WordPress or Joomla) this is the inherent behavior. Header/footer content, and other areas depending on your use of widgets, etc. will automatically display the same content on every page. This content is easy to update site-wide in one location. Content management systems excel in this area.
If you are building the site from static files, and you are using a scripting language of some kind (such as PHP, ASP, etc) the use of includes would be a good option. Simply call the repeated block of code wherever you'd like to insert it on each page.
For example, if using PHP, you have a file that contains your legal text in the footer called footer_legal.php
. Anytime you wished to include this content, you simply add the line include('footer_legal.php');
and the insertion happens.
Upvotes: 1