Html pages in separate sub-folders?

Hi,
I’ve been building my site for a while now and it’s getting quite large.

Is it possible to put html pages into sub-folders within the site and link to them. I don’t have a problem linking to images in sub folders i.e <a href=“images/tree.jpg”>. images being the subfolder obviously. I can’t seem to get the linking right for a page though.

How can I do it? And then how would I link back to the index page or pages in the main folder?

Help please?
Thanks

Sara

You can use sub-folders freely, you just have to make a reference to them in the href part of the link.

For instance

root

[INDENT]products

[INDENT]product_x.html
product_y.html[/INDENT][/INDENT]

[INDENT]people

[INDENT]john_doe.html
jane_doe.html[/INDENT][/INDENT]

In root/index.html you can refer to john doe like this

<a href="people/john_doe.html">John Doe</a>

And you can go back to the index with

<a href="../index.html">Go back</a>

Just keep in mind that in any folder an index.html must be present or the directory listing may show.

And I might add that you would also use the …/ prefix to reference the css and image files from those pages as well.

Indeed!

In fact you must add a complete address for every resource you link.

I always reference files as /dir/file, makes it easier for testing and moving it from hosting provider, to hosting provider. I’ve always found references to …/ to be very amateurish.

Whilst not using the preceeding periods will reference the path to the server root, it will not work locally during testing unless you go to the trouble of setting up a web server on your local machine, and make sure the site is being built at the localhost root. If you keep track of the file structure, relative paths work fine.

I usually have 2 sites one a beta, and one a live. And sometimes a virtual server on my local site.

Thanks guioconnor, turns out a problem with the folders was stopping my links working - I wanted to make sure I was linking right before I looked deeper into the problem though. All sorted now.

drmadcow, when you say you reference files as /dir/file, what would be the address I would use to get back to the index page in the root directory if the folder containing the index.html was called ‘site’?

And if i work locally, i.e. generally running stuff on c: then using an external host site, wouldn’t I need to change all the specific addresses to make it work elsewhere than my computer? Or have I missed your point?

Which way would people recommend?
As I say, I’m fairly new to all this stuff

Thanks for your help

Ahhh so instead of being in /images/file.jpg everything is like /site/images/file.jpg? If so I’d fix that up and do something like 301 everything in /site/ to /, and wait for it all to transfer over. Other wise the index.htm would be in /site/. Make sure you never refer to something as index.htm as that can divide up your internal link weight. Google can get confused and consider it two different pages. Cheers.

Mhmm… I’m not very sure of that!

I don’t usually don’t like …/ but there is a risk in assuming you can use an absolute path inside the server.

Sometimes you develop a module that can be either in
www.adomain.com/
or
www.anotherdomain/module/
and the absolute path will lack mobility.

For instance I, like you, have a development area to hold my projects, but because I can’t have a spare domain for each project usually a project like
www.myproject.com
would have an equivalent
www.mydevelopment.com/myproject
And your solution will crash it!

I deal with this with path variables on the server side, but I think this is too much for the scope of this discussion.

If one is using static HTML instead of server side scripting I don’t think …/ is excessively amateurish when mobility is needed, after all, keeping consistency on the internal structure of your site/module is a safer bet than the location of it :slight_smile:

GrinZ As a rule thats how I build. Granted sometimes I have to use a subdirectory like you pointed out, but I will refer to it as /ProjectDir/File.htm.

But then you have to change all the links when moving it, don’t you? I can’t see why this is better than using …/

I would prefer to use some server-side scripting where I only have to change a single variable to change the path, but I wouldn’t consider a search & replace in all the documents of a site.

Why would I have to?! If I’m ever moving it the only thing that changes is the hostname. as everything is relative of / and not with the hostname there are no complications. My CMS runs in /WSCMS/, and it is coded to be in /WSCMS/. Why would there be a need to change this. And if I ever have the need with Dreamweaver a simple global search can be very useful :slight_smile:

Well, exactly, it seems the code is tied to the external structure of the site, that’s what I meant :wink:

I agree, but I don’t understand why this is better than no global search at all.