Question Details

No question body available.

Tags

advice php html

Answers (1)

July 20, 2026 Score: 3 Rep: 82,025 Quality: Medium Completeness: 60%

The idea is good, but the implementation is not mature-enough. You need to consider many things here, listing them would be too much, firstly because I lack context of your project and secondly there are too many concerns. Therefore, instead, I'm laying out some ideas.

You are doing some templating to avoid code-duplication. Which is cool. But let's look at your code. It contains the entirety of head and in part the body. What if you are going to create themes? Will they all have a different head? Unlikely. So if you create multiple themse sharing the same head, then you duplicate code...

Instead, you should create a head.php template that contains your head and separate that concern from other templates. Your head.php should look like this:

Similarly, you could create a template that's gonna be a wrapper, you could call it body.php and it would look like this:

and a layout.php that's gonna look like this: