Include external html file inside of another html file

I am in the process of migrating my site to Netlify (free tier) but I need to figure out how to convert this php code into something that can be used in Netlify. I am aware that php does not run in Netlify.

My site currently uses PHP to include external html files. For example I have something like this:

<?php require("./menu.php"); ?>
<?php require("./footer.php"); ?>

How can include external html files inside of another html file in Netlify?

Hi, @CodeBrah123. Netlify is normally used in tandem with a static site generator (SSG). It would the the SSG that would handle the merging of headers and footers into the pages on the site. In other words, this isn’t something that Netlify handles directly. This is something handled by the SSG tool used to build the site.

There are hundreds of SSGs and you can find a list that includes of many of them here:

Note, every SSG is free to handle file includes in its own way. That page has 347 SSGs at the time I write this. Netlify doesn’t enforce one pattern or another. So, the answer about how to do this will depend on which SSG is being used. You are even free to write your own custom code to do this (which is the equivalent of making your own custom SSG).

If you haven’t selected an SSG yet, you might consider something like Hugo. It is an open-source SSG ( Apache License 2.0) with a public repo and written in Go so it is very performant. It has a
“Partial Templates” feature that makes doing what you want to do possible:

That is just one solution as each SSG is different. Which SSG to use (if any) is up to you.

Please reply anytime if there are other questions about this.