What method to use to build a website with a static layout/template?
I've been building websites for about 5 years now, never more than simple HTML in Dreamweaver. I'm about to build a web site that essentially needs a header/menu-sidebar/bg to stay the same on every single page, and only the content on each page to be different. Pretty much, I want to make a template - HOWEVER - how can I make this "template" come from a source file? In other words, if I want to change a menu item or header in the future, I don't want to change every single page- just the "template" file. Is this something I would do with CSS? Where do I start or learn about this?
Public Comments
- You might want to look at using Server Side Includes (SSI) to do this. http://httpd.apache.org/docs/1.3/howto/ssi.html It also makes using things like Google Analytics a lot easier, you just put their code into your footer file. The main thing to be careful about is that your syntax checker may fail to pick up some errors because the SSI files do not include the header. You can use an online validator to check for this. Also, some servers require that you use the .shtml extension for pages that include scripting or SSI.
- To address exactly the same problem - Server side technologies came into play. (But they also address a lot more issues than that..) Solution 1. But for your problem, if you know a little bit of PHP, its a one line game (OR if you know your server uses PHP, just close your eyes and blindly include the following line on every html page you create) <?php include("path_to_your_menu_HTML_file_name"); ?> (of course, replace path_to_you_menu_HTML_file_name with the one appropriate for your context!) Now with that line, you can put your menu in one file (the one you are referring to in the above code), and then include the rest of the matter in all your other files. A little caveat though - you will have to name all your files as ending with .php (not .htm or .html). So, if you know your server is running PHP and you have renamed all your files on the website from .htm (or .html) to .php and included the above code. You are all set to go. The advantage fo this solution is that it doesn't depend on the client side browser, so you are sure that your client receives HTML only. Solution 2. (Easiest One) Use iframes... Use this code: <iframe src="included.html" width="450" height="400"> Adjust the src, width and height according to your need. The advantage for you is that it keeps you in the domain of HTML. (no renaming of files!) The thing with inline frames (the code above - iframe) is that it breaks on very old browsers (maybe a non-issue today) and search engines do not cache it. Here is an excellent resource on iframes: http://www.htmlhelp.com/reference/html40/special/iframe.html
Powered by Yahoo! Answers