Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a template in HTML?

Tags:

html

templates

I started creating web pages in plain HTML. I have a header, main content and a footer. The main content is divided into two, left and right content. Everything is the same on all pages except for the right content. Now I have about 15 pages. This is very tiresome if I make some changes on the other static pages (header, footer and left side content) as I have to go through all pages.

How can I create one HTML file for each static area and how am I going to integrate it?

like image 895
Saint Dee Avatar asked Apr 21 '13 14:04

Saint Dee


People also ask

What is a template in HTML?

The <template> tag is used as a container to hold some HTML content hidden from the user when the page loads. The content inside <template> can be rendered later with a JavaScript. You can use the <template> tag if you have some HTML code you want to use over and over again, but not until you ask for it.


1 Answers

There are a couple of ways to do this.

If you are working purely with HTML, then you can use a 'server side include' -- this is a tag which allows you to load a file into the page (see http://en.wikipedia.org/wiki/Server_Side_Includes). Whoever is hosting your website has to support this.

<!--#include virtual="../quote.txt" -->

If youe web host happen to use PHP, you can do this using the include method (see http://php.net/manual/en/function.include.php):

<?php include('path_to_file/file.htm');?>

This will include the file at the point you place the tag. But again, whoever is hosting your site needs to support this.

There are other methods of doing this, bit these are the two I make use of.

like image 161
swshaun Avatar answered Nov 27 '22 06:11

swshaun