How to make the same layout for all web pages

I am currently working on HTML. I want to ask a question about website development. I am developing a website where the basic layout remains the same as the menu, side menu, etc., but only the content changes. I currently have a separate .html file for all web pages. Can someone tell me if there is a way by which I can make a separate file shared with everyone and call it in my html file. I heard about CSS, but it will only change the style and layout. thanks

+8
html css html5
source share
5 answers

If your HTTP server ( apache 2 and IIS ) supports Server side includes , then you can simply add another HTML file:

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

no server side needed then just HTML

+13
source share

This is a very important topic to include in only one answer. So, I will give only the logical part.

Divide your template into several fragments, for example:

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

Now include this common part on 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 the logical part applying the concept of your code.

+5
source share

Yes, your best bet is server-side language, as Adam said. Absolutely avoid using old html frames: they are outdated and cause a certain amount of problems both on the programming side and on Google optimization.

Using the server language, you will still have whole 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!

+1
source share

It is best in the long run to use a server-side language like ASP.net or PHP

0
source share

I do not believe that this is possible strictly through HTML. However, you can use server side scripts such as PHP to do this. What you are talking about is a template and is used quite often. You want your menu items (and CSS) and your header / footer code on separate pages. Thus, if you make changes to the menu or to the header / footer, it will be displayed on all pages (written using PHP) that you created using the template method.

You will need menu.html, header.html and footer.html in a place accessible to your main page code. That is, you must use the template method to record the contents of your pages.

An example psuedo code in PHP would be:

 <?php include('header.html'); include('menu.html'); echo "Your main content items here"; include('footer.html'); ?> 
0
source share

All Articles