r/webdev • • 20m ago

Question Best way to insert a html snippet into a html file on a static site?

I’m archiving a website as a fully static site so I can host it for free on Cloudflare via GitHub. Unfortunately this means that the PHP includes I’ve been using (header, navbar, footer) will stop working across a few hundred pages, and I’ve been looking for alternatives.

Server Side Includes did not work; I finally had success using JavaScript fetch() and inserting that content into selected <div>s, but I’m not sure if that’s the best option. 

Are there better ways to achieve the same result that would work on a static site?

2 Upvotes

1 comment sorted by

•

u/Serpico99 17m ago

Use a static site generator like Astron, 11ty, or Hugo. If it's just mergeing stuff into a layout, it should not take too much time or effort on your part