Reputation: 2368
On my personal website I have lots of items that are re-used quite a lot. For example I might have two different landing pages with slightly different layout, but almost all the same content. For example:
landing-1.php:
include( 'header.php' );
include( 'about-us.php' );
include( 'contact-us.php' );
landing-2.php:
include( 'header.php' );
include( 'portfolio.php' );
include( 'contact-us.php' );
Now I am looking for an alternative so that I can create static HTML pages instead of having to use PHP just for the inclusions. Ideally this script would grab the content of the included files and paste it at the right place. It probably wouldn't even be PHP.
(I hope this question is suited for SO, or is there another SE site that I should use?)
Upvotes: 0
Views: 669
Reputation: 943605
Template Toolkit has INCLUDE functionality and comes with the ttree utility for generating static pages from templates.
Upvotes: 1
Reputation: 49376
If you're looking to do this dynamically, and are using Apache, you might want to look at server side includes. They're much lighter weight than a full PHP script. IIS has a similar module, as does nginx.
If, instead, you want to generate the HTML once and store it, you can use your pre-existing PHP pages. Just use php
on the command line, passing your page to the interpreter. If you've not used HTTP specific PHP functionality in your pages (i.e. $_COOKIES
etc), then it will spit out the finished HTML for you to store and serve like any other static content.
Upvotes: 3