Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make same layout for all web pages

Tags:

html

css

I am currently working on HTML I want to ask a question about website development.I am developing a website in which the basic layout remains same like menu, side menu etc but only the content changes.Currently I have make separate .html file for all web pages. Can any one tell me is there a way through which I can make a separate file having etc common to all and call it in my html file.I have heard about CSS but it will only change the style and layout. thanks

like image 204
mainajaved Avatar asked Mar 26 '12 13:03

mainajaved


3 Answers

If your HTTP (apache 2 and IIS do) server supports Server Side Includes then you can just include another HTML file :

<!--#include file="header.html"-->

your content

<!--#include file="footer.html"-->

no need for a server side language then - just plain HTML

like image 161
Manse Avatar answered Oct 23 '22 12:10

Manse


This is very big topic to include in just one answer. SO I will give only the logical part.

Separate your template into multiple chunks like:

1. header.php
2. leftSidebar.php
4. rightsidebar.php
5. footer.php

Now, include these common part on your every page.

For example: index.php

<?php

    include "header.php";
    include "leftSidebar.php";
    echo "<div>".$thedifferentpart."</div>"; //Change only this part on every other page you will create.
    include "footer.php";

?>

NOTE: This is only a logical part, applying the concept on your code

like image 24
Starx Avatar answered Oct 23 '22 14:10

Starx


Yes, your best bet is a server side language, as Adam said. Absolutely avoid using the old style html frames: they're deprecated, and cause a certain number of problems, both on the programming side and on google optimization.

By using a server side language, you'll still have entire pages, but they will be partially generated by php (or asp) by printing more files into one. For example:

http://www.php.net/manual/en/function.include.php

Bye!

like image 43
Luca Reghellin Avatar answered Oct 23 '22 14:10

Luca Reghellin