Wednesday, March 11, 2020

How to Template Your Site in HTML and PHP

How to Template Your Site in HTML and PHP When each page of your website follows the same design theme, it is  easy to create a template for the site using HTML and PHP. The specific pages of the site hold only their content and not their design. This makes design changes easy because changes take place on all the pages of the website at once, and there is no need to individually update specific pages when the design changes. Creating a Site Template The first thing you need to do is create a file called header.php. This file holds all the page design elements that come before the content. Here is an example: My Site My Site Title My Site menu goes here........... Choice 1 | Choice 2 | Choice 3 Next, make a file called footer.php. This file contains all the site design information that goes beneath the content. Here is an example: Copyright 2008 My Site Finally, create the content pages for your site. In this file you:   Call the header file  (header.php)Put in the page-specific contentCall the footer file (footer.php) Here is an example of how to do this: Sub-Page Title Here is the specific content of this page.... Tips Remember to save all your files with the .php extension.You can have more than a header and a footer. If needed, create other files to include in the middle and call them the same way.Couple your templates with the use of a style sheet to change style within the page-exclusive content.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.