Is it possible to use PHP includes in my app?


Hi, I have an HTML file that is quite long. I would like to break it up into smaller parts so it is more manageable to work with.

Outside of Glitch, I would normally achieve this by renaming the index.html to index.php and then using PHP Includes within the HTML like the below example;

include 'components/head.html';
include 'componentsbody.html';

As described, for example in this question on Stack Overflow.

If I rename my .html file to .php on glitch then go to view it, its showing me the file directory rather than resolving to the index.php file.

Here is an example project here on Glitch.

Is it possible to do what I am trying here in Glitch? If not, does anyone have any suggestions for how to achieve the same result of a more manageable html doc. I have tried the js solution but this loads in parts of the page slower than others and is not as clean as the PHP solution.

Any help with this would be much appreciated.

PS I am not familiar with PHP at all, I just came across that solution a few years ago and do not use it beyond that specific case, if any potential solutions could be described with that in mind it would be much appreciated.



Hi, I have a solution to my problem. Using the handlebars example here on Glitch, I can achieve the same results. Thank you!