Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it bad to include header and footer as a template?

Tags:

html

css

php

I was wondering if it's the right thing to include the tags like etc via another page.

What I mean by that is:

<?php include_once("header.php")?>
The content for each individual page
<?php include_once("footer.php")?>

Header.php contains:

<!DOCTYPE html>
<head>
<title>My Website</title>
</head>
<body>

Footer.php contains:

</body>
</html>

I am using it that way because when I have a lot of pages, it's a lot easier to just change one/two page(s). That way I spare time.

But the question is, is it bad to use a "template" style for my website?

( I saw some similair questions like this one but they didn't really answer my question, that's why I started a new topic - Sorry if it's wrong )

like image 560
Ahmed Avatar asked Aug 11 '13 15:08

Ahmed


People also ask

How do I create a header and footer template?

On the Layout tab, under View, click Page Layout. On the Layout tab, under Page Setup, click Header & Footer. Choose from a list of standard headers or footers by going to the Header or Footer pop-up menu, and clicking the header or footer that you want.

How do I create a header and footer template in Word?

In the "Header & Footer Tools" tab, select "Quick Parts." From the dropdown, select "Fields." This will open a dialog box. Select "Page" from the field names list. Select a page number format and click "OK." You will get an updating page number field on the right. Thanks!


1 Answers

No problem with this I think - it's certainly better than duplicating the same content across multiple pages. Don't Repeat Yourself is a core tenant of programming, and this approach helps in that regard. The performance impact of the PHP includes is absolutely minimal and not worth worrying about, compared to advantage of easier maintenance.

You might be able to go further still though. Do you really need to repeat the includes on every page ? If all the pages have identical headers and footers, then you could make just one page that has them, and an area for dynamic content in the middle instead (this is the approach ASP.NET takes).

like image 125
Michael Low Avatar answered Sep 23 '22 05:09

Michael Low