cancel
Showing results for 
Search instead for 
Did you mean: 

Linking to common HTML

Denzil
Grafter
Posts: 1,733
Registered: ‎31-07-2007

Linking to common HTML

I am no expert on this, but I am working on a new website for my archery club, and teaching myself some CSS into the bargain. There is a common chunk of html in all the pages which has the content of a sidebar with the main menu and news headlines. There aren't that many pages, so it is not too big a deal to copy and paste them all when I do an update, but I would like to find some simple way of having one chunk of html that all the pages link to.
I know I could use frames, but I would rather not. I would just like to put a separate small html file into the flow in the same way as you would with an image. Any ideas?
6 REPLIES 6
jelv
Community Veteran
Posts: 26,786
Thanks: 990
Fixes: 10
Registered: ‎10-04-2007

Re: Linking to common HTML

You could use server side includes. You put the common code in a separate file and then where you want it to appear you have
<!--#include virtual="path/includefile.xxx"-->

The path is required if the included file is not in the same directory.
The will also need to make additions to .htaccess to tell the webserver which pages should be checked for includes
AddHandler server-parsed .shtml .htm
AddType text/html shtml htm

All my pages which have includes are shtml not html. You could enable it for html but that means it will check for includes on all web pages before they are delivered.
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
Denzil
Grafter
Posts: 1,733
Registered: ‎31-07-2007

Re: Linking to common HTML

Thanks, jelv, that looks like the kind of thing I need.
The whole point is that all the pages have the same bit of code, so it will have to check all the pages anyway. I might add this is not hosted by PN, so I guess I'll have to check that the host has that enabled.
samuria
Community Veteran
Posts: 1,577
Thanks: 3
Registered: ‎13-04-2007

Re: Linking to common HTML

What software are you using as some like MS Expression let you have a master page and all other pages come from that page so if you chamge the master page it changes every page in the site simple.
You can get MS Expression as a free trial
Denzil
Grafter
Posts: 1,733
Registered: ‎31-07-2007

Re: Linking to common HTML

MS Shocked spit, spit. No, using Suse 10 on a desktop and Ubuntu 7.10 on a lappy. I use Kompozer, but also doing it manually with a text editor.
You would have thought there would be a way of doing it in html, e.g. <html src="xxx.html"> or somesuch, but no, that would be too easy. Server side includes seem to be simple enough, though, unless anyone has any better ideas.
samuria
Community Veteran
Posts: 1,577
Thanks: 3
Registered: ‎13-04-2007

Re: Linking to common HTML

You could do most of it with CCS as that can handle the menu etc depending what the news is?  Using the same CCS for ever page would solve it
Denzil
Grafter
Posts: 1,733
Registered: ‎31-07-2007

Re: Linking to common HTML

I already have a single styleheet for all the pages. Surely the whole point of CSS is that is does not include content? The style is in the CSS, the content is in the HTML. The content of the common section i.e. link addresses, text etc has to be in the HTML.