1

I am not sure how ask this. I was wanting to build a static website with reusable header & footer.

<body>
   <include src="./header.html"></include>

   Content

   <include src="./footer.html"></include>
</body>

Since markup above doesn't exist in HTML, can it be done using XML client-side(browser)? File includes would be same origin obviously.

Xarcell
  • 2,011
  • 6
  • 33
  • 65
  • Lookup "`Server Side Includes`" (SSI) – Stewart Jul 29 '22 at 20:11
  • 1
    https://stackoverflow.com/a/5127928/14419 – Mads Hansen Jul 29 '22 at 20:15
  • Not XML, but as an alternative, with just `fetch('file.html').then(r => r.text()).then(html => someElement.outerHTML = html)` you can load & render a HTML file (_adding some error handling wouldn't hurt though_). This will probably make your site index better on search engines than any XML-based solution. Note: doesn't work on `file://` protocol, so run a local web server. – RickN Jul 29 '22 at 20:47

0 Answers0