Skip to content Skip to sidebar Skip to footer

Html Template File

I know this is a beginner's question, but I've been searching online and all I can find are 'free website templates' that I can download. The question is: How can I write a segment

Solution 1:

You are describing server side includes.

Server Side Includes are useful for including a common piece of code throughout a site, such as a page header, a page footer and a navigation menu.

Example of usage:

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

This will add the text of quote.txt to the page - if you add it to multiple pages, you can make your change in this one file and it will show on all pages in was included in.

Different web servers have different support and additional features for these, so you need to check the documentation for yours.


Many websites that need dynamic features (like fetching data from a database) will use some kind of server side scripting language for this kind of functionality - examples include PHP, Perl, ASP.NET, JSP and many more.

Solution 2:

Typically a server-side scripting language such as PHP is used to dynamically include such files. Client-side solutions usually involve iframes, etc. which is usually not preferred.

Solution 3:

This kind of behaviour can only (sensibly) be achieved through the use of sevrer side languages like php or asp.

Non-sensible ways of handling this would include iframes blech or framesets double-blech.

Solution 4:

For plain HTML you just use include:

<!--#include FILE="menu.inc" -->

Solution 5:

There are two places you can do this:

  1. Server side programming at runtime (which allows for quick updates to templates but needs server support)
  2. Something at build time (which simplifies cache control and doesn't require anything to run on the server)

The two basic approaches to this are includes (simple) and full template systems (powerful).

For a runtime include system, the popular choice is PHP's include function. An alternative is SSI. You can even use a C preprocessor.

Template systems include PHP's Smarty.

My weapon of choice is Template-Toolkit, which can be used via Perl at runtime and comes with ttree for use at build time.

Less sane options involving making the client do it and include frames and JavaScript.

Post a Comment for "Html Template File"