Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting up a html page and loading it through header?

Tags:

html

header

I am using HTML5, and would like to speed up the creation and editing of my standard HTML template by splitting it into three separate HTML files.

  • header.html
  • content.html (this will be edited and will have other names e.g. home)
  • footer.html

I have looked at the following resources, but I am not sure if this is possible or how to go about it.

http://www.w3schools.com/html/html_head.asp

http://www.w3schools.com/tags/tag_link.asp

In PHP I would just include the files in the right order. Is there an equivelant in just a plain HTML site?

I have googled this, but I don't think Im searching for the right term. I would appreciate any information, or resources available!

Thanks for your time!

like image 840
tomaytotomato Avatar asked Oct 30 '25 13:10

tomaytotomato


2 Answers

For just a static HTML site, there is no html-only way to include files the way you are trying to. You may be able to use server-side includes depending on your server, but by that point, you might as well just use PHP.

Another option would be to make extensive use of Javascript to load the page pieces after the main part of the page is already loaded.

In all cases, though, you will have a major reduction in performance, since a server request is slow. If you need to use templates, just use a dynamic language like PHP.

like image 68
cdeszaq Avatar answered Nov 02 '25 02:11

cdeszaq


You can't do it cleanly with HTML. You could use iFrames, but that's far from clean. The optimal solution would be to use PHP. It will also save you the requests from the browser.

like image 21
Madara's Ghost Avatar answered Nov 02 '25 04:11

Madara's Ghost



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!