Hey all, I need a bit of help. I'm trying to develop some include files for my website, but I'm having a hard time getting them to work. The overall process seems relatively simple, but every article I read provides a different set of instructions on how to accomplish this. Given the fact that I have no formal training in web design I thought I'd turn here for some help. I prefer to keep .htm extensions on my website and I believe I'll need to make some edits to my .htaccess file. I tried a few suggested snippets of code last night to no avail. Can someone provide some advice? I'm working with a basic html website hoted on a Linux server. If it helps, I could post the contents of my .htaccess file Thanks in advance!
You will need to be more specific before anyone can help you. Like are you talking server side or client side include files? If server side, what are you using server side? PHP? Or? If client side, are they javascript files or what? Exactly what do you have available and exactly what do you need to do?
Ok, so here's where my lack of formal training will probably show a bit... I believe I'm looking for server side includes. I have a paid hosting account and upload my entire website to a file server. I plan to place the include files in a folder on that server. However, I'm open to suggestions. My website runs on basic html files, but my webhost does allow php, asp, etc. I checked and my webhost does allow SSI. Again, I'm open to suggestions on which is the best to use. Thanks again.
I think the first thing that you should do is to do a thorough analysis of what "server side" and what "client side" mean in relationship to programming. From what I see in your last post I think (but do not know) that you are very fuzzy on what each of them mean.
My 2c. 1) There's no particular reason to keep .htm extension. I use .php a lot and remove the extension via htaccess: Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php Code (markup): ** Remember all links should not include file extensions: <a href="about-us">About Us</a> Code (markup):
Whoops. And then insert snippets like a common header or footer like this into body: <?php include_once('includes/header.php'); ?> Code (markup):
I use SSI (server side includes) on all my sites. Headers, footers, navigation, Google ads, etc. I usually have a folder named 'inc' where I load all my includes. The reason I use a folder for the includes is partly housekeeping, but it also allows me to disallow that folder in my 'robots.txt' file Includes can have any extension you want. For HTML pages (non-PHP), I normally use files like 'head.html', 'foot.html', etc When I want to call an include, I use <!--#include virtual="/inc/head.html" --> Code (markup): SSI also allow you to do some neat stuff with dates. One example is an automatic update on your copyright notice. There is some good stuff on the Apache site. http://httpd.apache.org/docs/1.3/howto/ssi.html
I recommend you read this about server side includes. You can tell your server to parse .htm files by adding this into the .htacess file: AddType text/html .htm AddHandler server-parsed .htm Options +Includes
Thanks for the advice everone. I'm going to do a bit more research into this topic since, like most things I've experienced with web design, there are dozens of different ways to accomplish the same goal - each with varying pro's and con's. I only want to do this once, so I want to be sure what I pick is the best way. I suspect I'll be back in a few days, but you guys have provided some great leads for me to chase down and play with. Thanks!