Skip to content Skip to sidebar Skip to footer

How To Make Webpages With The Same Design

After many practice websites, I have finally made a website that is published. The problem is that if I need to change the design, i.e what is after and before (in coding) of the t

Solution 1:

You can use PHP to include header and footer.

For example, you put all the header and the menu in "header.html" and all the footer, copyright, ... in "footer.html".

The, create a index.php. In this page, you may write like that :

<?phpinclude'header.html'; ?><p>body</p><?phpinclude'footer.html'; ?>

Solution 2:

Quite easy; seperate your template files.

// header.php
<html><head><title>My beautiful website</title><scriptsrc="script.js"></script>
        ....
    </head><body>

.

// footer.php
    </body>
</html>

.

// content.php
<?phpinclude('header.php'); ?><h1>Welcome on my website</h1><p>Lorem ipsum</p><?phpinclude('footer.php'); ?>

Now if you want to change something, change header.php and the changes will be visible on every content page.

Note; you can also turn things around (include 'content.php' from within a base template file)

Solution 3:

Divide your code into 3 .php files

  1. header.php - everything above your content
  2. content.php - your content
  3. footer.php - everything under your content

Then in your index.php file ( and all the others ) just include them, like:

<?php$meta = 'This page meta info';

include('header.php');
include('content.php');
include('footer.php');
?>

header.php

<html>
    <meta="<?phpecho$meta; ?>" />
    ...

Solution 4:

you can use includes <?php include('templates/global_header.tpl') ?>

to do this you need your main pages to have the extention .php instead of html.

Post a Comment for "How To Make Webpages With The Same Design"