Using php includes for linking pages together

Using php includes for linking pages together


So I was curious… for those of you that create (static) websites. Do you separate the various sections of your pages (header, sidebar, footer etc.) and link them together using php includes? Is this common practice? Or should I be looking at using some form of CMS to link pages together?


Combining separate parts of pages (i.e. header, body, sidebar, footer, etc.) together is common practice whether using PHP includes, Pug includes, EJS includes, or even similar ideas like components. Using includes to link pages together is not. A CMS is used to manage uploads, posts, images, pages, etc. Popular CMS like WordPress use includes in their code.


Since you didn’t specify to only php backends, I’d like to tell how it’s done in angular:
You code every section of your body and link it to a single index page. The navbar has it’s own component with their interactions as well as the body and pretty much anything you might want to add.

A usual index file might look like this:
(with closing brackets that I can’t use in this editor)


Each of this components has it’s own html, css and typerscript file, so you can merge them as you like, the router is the body that will dynamically load the components the router points to.

In case you’re interested!