Forum Moderators: mack
At the moment, the site in question is going to be a (potentially large) content website, with no fancy databases or anything like that. To date, I've been purely hand coding in HTML with heavy use of CSS, and have been pleased with the overall look and feel.
This is all well and good, but the problem is that I foresee tremendous headaches if I decide to change the layout - even for something as comparatively minor as adding an additional box on the left panel. What are some realistic options apart from manually updating the pages?
- SSI. The problem with this is that it presumably makes it way harder to "test" web pages when offline or when they aren't published yet.
- DreamWeaver templates. My main gripe here is that DreamWeaver seems to handle CSS WYSIWYG functions pretty badly - i.e. I sometimes see inexplicable black boxes around perfectly well-defined CSS divs. Furthermore, I wouldn't want to get too dependent on Dreamweaver for linkages between template and instance pages, especially if the linkages are broken, which I've heard can easily happen?
- PHP etc. Again, isn't it such a pain to easily preview PHP files residing on your hard drive?
- A CMS system. Definitely not - I've had experience with several of them. Installation is often a pain, and I invariably find them lacking in flexibility (short of complicated customization programming which seems harder than coding from scratch).
What do you guys think? Does it sound a bit naive to try to tackle what could end up to be a fairly extensive site merely by handcoding in HTML/CSS? Any advice would be much appreciated!
- SSI. The problem with this is that it presumably makes it way harder to "test" web pages when offline or when they aren't published yet.
Why not just install a test webserver locally? It's idea to have a Linux box, but Apache installs easily and runs well enough on Windows. You're not demanding a lot of it - just basic page serving and SSI.
I don't have a Linux box handy, but for instance if I installed Apache on my Windows XP laptop, would that already be sufficient to test offline? I presume I wouldn't need to be connected to the internet to use Apache to test local documents.
Also, I presume from your reply that using SSIs is a very popular way to have flexible templates among web developers? I was thinking along the lines of having one template document for my pages, and only a single DIV's worth of unique content for each individual page, e.g.:
[Include Stuff]
<DIV>
[all content for that page, including sub divs etc]
</DIV>
Is this a common approach? Thanks again! :)
I'd guess that MOST big commercial HTML authoring packages now include some sort of local webserver in the box to allow for local testing of at least includes, so it's a popular approach.
No, you don't have to expose your test site to the Internet to test. You will reference it as "localhost" in the browser bar.
The approach you are suggesting looks good. I would add an include at the bottom of each page as well, though. It's always a good idea for divs to appear in the order in which they should be read, even though CSS ran reposition them. This way, they will make sense if read in a non-CSS browser. Keep this in mind when orgainzing your pages internally as well.
Did you know that Apache has a way to automatically do an include at the beginning and end of every page? That way, you don't even have to remember to put the includes on your pages. Now, if I could remember how to do this... (I don't currently do this, as I serve dynamic pages.)
For maximum flexibility, it's best to have includes in both the title and body sections of your documents. Here's an example:
<HTML>
<HEAD>
<TITLE>All Your Examples Are Belong To Us!</TITLE>
<!--#include file="/sitemeta.inc"-->
</HEAD>
<BODY>
<!--include file="/siteheader.inc"-->
<div class=content>
<P>Blah, blah, blah</P>
</div>
<!--#include file="sitefooter.inc"-->
</BODY>
</HTML>
sitemeta.inc contains your site-wide meta tags, javascript, and CSS. (Or, probably references to further .inc files, themselves containing references to javascript and CSS files.)
siteheader.inc and sitefooter.inc don't necessarily contain literal headers and footers, but whatever you want to wrap your content in.
I do believe there is a module that will allow you to filter content and include files based on regular expressions. But it's not included in the Apache distribution.
So, there is still a way to do this without having to actually put the includes in each content file. (At worst, you could use mod_ext_filter and pipe through grep...)
Ahhhh... it is coming back.... I'm thinking of the Apache::Footer module used with mod_perl. Apache::Sandwich will put your content between a header and footer, but this won't insert metas, etc. A better solution is Apache::SimpleReplace, which inserts the content of your .html pages into a template.
But it's not so bad simply to have a simple starter file like the one above that you just use whenever you start a new page. Just give some thought to where you want to put the includes for maximum flexibility.
I would use php or asp as a way of adding your includes to the pages, that way if you ever decide to change your site to a database driven app you will not need to worry about having to change all of your URL's.
Also for include files do not use the .inc extension because if anyone guesses the filename they will be able to 'see' the file code (which if it contains only your navigation is fine, but when it comes to db connections it is not). Use the same extension as the other pages and your include will be parsed and only the output will be visible.
do not use the .inc extension because if anyone guesses the filename they will be able to 'see' the file code (which if it contains only your navigation is fine, but when it comes to db connections it is not
DANGER, WILL ROBINSON!
This doesn't solve the problem. Any file name you use is ultimately "guessable" with enough tries. (Of course, you could make the file names completely random.)
First, this is only an issue if you are using php, etc. You can't "make database connections" from SSI files. They are just HTML.
If you are including files from PHP code, do NOT put the included files in a web-accessible directory!
If you don't want people to be able to see your includes, here are two good choices, which apply either to SSI or PHP. (Or other inline languages, as well.)
- Put the included files in a seperate directory. Do not make that directory visible through the server. SSI (or the language you are using) will still be able to access the files, but users will not be able to fetch them.
- Make them all a certain extension, or include some common pattern in the file names and don't permit your webserver to serve files with that extension (or pattern).
A few additional questions:
1. Is having all your files named as .shtml the most common approach? Are there any potential downsides to be wary of?
2. In order to get the includes to be parsed I had to make a number of changes to the httpd.conf file of the Apache installation. Do practically all web hosts allow editing of this config file?
3. Theoretically I've gotten it to "work" on my local machine except for the fact that I get a weird pair of characters appearing on the page before my include output. All my .inc file has is a paragraph tag and a single word, and what I get on the screen is:
ÿþWord
The same occurs if I for instance have a DIV tag and an image in the .inc file. Any idea what that's about? Thanks in advance!
For the problem with extra characters, it looks like you have an encoding problem - the characters resemble a Unicode byte-order mark. A related thread:
[webmasterworld.com...]
See also:
[webmasterworld.com...]
You may need to resave the files with windows-1252 encoding to remove the byte-order mark. What character encoding are you defining for your pages?
But yeah, currently I'm just handcoding in Wordpad and saving the files as Text Files (of course with .shtml extensions), and the line I use right at the top is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Provided this current handcoding approach is fraught with danger, do you have any recommendations for a good free text editor and format in which to save the files to avoid headaches in the future?
Also, is it common practice when you start with a web hosting service to have to delve into the Apache config files and manually enable SSI? Thanks in advance!
As for the doctype, it's not the best choice when authoring new pages. I would recommend starting with option 1 as given in the following thread:
You should also be declaring your character encoding on each page. For more information, see:
For the text editor, anything with syntax hilighting is ideal. I'm a Linux user so I'm not up to date with text editor recommendations for Windows, but I have used EditPlus in the past (not sure it's free though). You should not use Wordpad or Notepad as they are not able to handle character encoding sufficiently well.