#include for HTML?

Joined
Apr 29, 2006
Messages
4,576
Reaction score
378
Points
83
Location
St. Somewhere
Your Mac's Specs
Mac Studio, M1 Max, 32 GB RAM, 2 TB SSD
A noob web page coder's question:

I am "hand coding" a new web site in HTML, which I have learned by reading the very helpful book "HTML Goodies". Being "self taught", there seem to be a few gaps in my knowledge!

A key one is this. My web site will have numerous pages, and they will all have an identical navigation pane that allows you to move between pages. Rather than copy the HTML code for this panel over and over into each page's source, I would like to write up this page section as a separate HTML file and somehow include into each page's source, rather like the #include directive does in C/C++ source code.

Is there a way to do this in HTML?
 

Del


Joined
Dec 24, 2006
Messages
901
Reaction score
15
Points
18
Location
N. Ireland
Your Mac's Specs
Mac Pro 2xQuad core 2.8GHZ
Then you need to learn php my friend

Code:
<php
   @include_once('name_of_file_to_include');
?>
 
OP
mac57
Joined
Apr 29, 2006
Messages
4,576
Reaction score
378
Points
83
Location
St. Somewhere
Your Mac's Specs
Mac Studio, M1 Max, 32 GB RAM, 2 TB SSD
You may be right! However, for now I will stick to my original question!

Does anyone know how to do this in HTML?
 
Joined
Jan 8, 2005
Messages
6,188
Reaction score
254
Points
83
Location
New Jersey
Your Mac's Specs
Mac Pro 8x3.0ghz 12gb ram 8800GT , MBP 2.16 2GB Ram 17 inch.
not possible, there is no #include in HTML code. You could do it via frame sets (which are a bad design mistake) or you can make the nav bar in flash and just embed the flash file at the top of each html page.
 
Joined
Jun 6, 2006
Messages
1,153
Reaction score
94
Points
48
Your Mac's Specs
MacBook 2.0GHz White, 512MB RAM, 60GB HDD
There are a few ways of doing it, the most '#include' like being SSI (Server Side Includes). This is supported by the Apache web server (that comes with OS X) but I'm not sure if it's turned on. It's certainly something to look at if you don't want to learn PHP just to use includes :)
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
If you're using straight html then you want to look into server side includes.

Keep in mind that some hosting services turn that feature off. They suck. You should be able to do a quick test to find out. If your just using your OS X box, then you can set it up if it is turned off.
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
Yep SSI, but that's not really html either. The ONLY way to do it in HTML is using iframes like was mentioned above, or frames (frameset) Both iframe and frameset's are not recommended, but it is the only answer to your question if you refuse to use a dynamic language.
 
OP
mac57
Joined
Apr 29, 2006
Messages
4,576
Reaction score
378
Points
83
Location
St. Somewhere
Your Mac's Specs
Mac Studio, M1 Max, 32 GB RAM, 2 TB SSD
Thanks everyone. Amazing! It is hard to believe that such an obvious feature doesn't exist in HTML! I guess that this is why I didn't find it in the HTML Goodies book.

I am guessing that any concept of macros doesn't exist either - this would be another way of achieving it.

I guess I will just copy and paste. As an old software designer, that makes me crazy, but I guess that is my only route.
 
Joined
Jun 6, 2006
Messages
1,153
Reaction score
94
Points
48
Your Mac's Specs
MacBook 2.0GHz White, 512MB RAM, 60GB HDD
Contrary to popular belief (and what many web designers might tell you), HTML isn't a programming language and so therefore wouldn't have things like macros, commands and statements to do anything. It's just a way of representing the way a document should be formatted. It's a document format, pure and simple.
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
Yep, what cazabam said. It's good to make that clarification. Im a web developer, so I work with PHP and MySQL etc and sure I know HTML since it's a huge part of what I do also, but anything that is dynamic I create using PHP, html is just a markup language "Hyper Text Markup Language" Anyways good luck and you should really look into PHP it would make your life much easier especially for what you are doing :)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top