0

Have a static website i am going to work on for a friend of about 4 distinct pages with a common footer, header, and nav. Just basic "this is who i am... this is what i have done... this is how to contact me." I would like to import the common sections either into a layout file where the contents that are specific to each page are included in, but if not, be able to include the common sections into each unique page. Just trying to avoid duplicative code.

I am familiae with Django and Laravel bur that would be overkill. Dont think ReactJS or Angular either since these are just static pages with almost no dynamic content, some animated behaviors that can be done with CSS, jQuery or VanillaJS.

A couple options came to mind and also some i read here on SO. The main options seem to be to use PHP include which seems pretty clean. Or use jQuery which seems a little messier. I would prefer to keep this project just HTML, JS, CSS if possible so the latter would seem the better option.

Are there any other options or lightweight, basic, HTML templating engines that can accomplish this? Again i dont need to render dynamic content nor database data.

Koby Douek
  • 16,156
  • 19
  • 74
  • 103
cjones
  • 8,384
  • 17
  • 81
  • 175

1 Answers1

0

You need to change your file extensions to .php So the end result would look like this:

<?php include 'header.php'; ?>
ALL YOUR CONTENT HERE
<?php include 'footer.php'; ?>
Tom
  • 4,257
  • 6
  • 33
  • 49