would like supporting files (css, images) in separate directories...

dhenry

Verified User
Joined
Jun 30, 2004
Messages
5
Location
Idaho
Hi all!

I am very new to all this and I am trying to create my website all on my own...and do it right from the start :D (organized file system, w3c standards, css instead of tables, etc.)

I hope this is the correct forum in which to post.

I would like to separate my files into separate directories to keep everything clean and organized. I'd like to put all my css files into a global "styles" directory and all my image files in an "images" directory so that any .html page can find those files no matter where in the file structure that page exists. (note: I do not want to restrict all my .html files to a particular directory)

I guess I have 2 questions:

1) where should I place these global directories?

2) how do I reference the files in these directories? (i.e. do I need a "full" path name and, if so, where exactly does that full path name begin since I am on a shared host?)

Thanks in advance for any advice you can give me!

Diane
 
Your questions are basic html questions and don't have anything to do with DirectAdmin.

But the answer is simple, so here goes:

You put the directories whereever you want inside your public_html directory, and you use relative links from the public_html directory to address them.

My I recommend you get a good book about html and css ?

Jeff
 
Jeff,

Thank you for your quick reply.

Although I stated that I am very new to this, I have read extensively and played around a bit with html and css. I realize that these questions are primarily html-related, however I'd have to disagree that they have nothing to do with DirectAdmin.

You see, I do know the difference between relative and absolute paths, but I am used to working directly on a server where I know where the root directory is. According to DirectAdmin File Manager, the absolute path to my css directory is: /domains/<my-domain.com>/public_html/css, yet when I use that path, my style sheet is not found. Same issue with my images.

I want the flexiblity (in anticipation of future growth) to be able move my pages up and down in my directory structure without having to modify all my (relative) links to my css and image files every time I move it. So I'd have to use absolute paths, right? Well, I can't find the absolute path.

I suppose a workaround would be to place a link to my css and images directories in every subdir I create, but I think that would get a bit too cumbersome (almost what I'd call obnoxious) and kinda defeats the purpose of a global directory. :rolleyes:

Any suggestions? Or am I over-complicating this.

Thanks again!

Diane
 
They're not found because the absolute path is not /domains/<my-domain.com>/public_html/css.

Presuming you put your css directory directly beneath your public_html directory, the absolute path is simply /css.

Because I place my css directory directly under [public_html], you can see an example by examining the source code to "http://www.nobaloney.net/index.html".

If you look at the source code you'll see on the first code line under the END META TAGS comment, this line:

<link href="css/nb1.css" type=text/css rel=stylesheet>

It's the last line in the <head> section, and it works because my stylesheet for this page is at "public_html/css/nb1.css".

For what it's worth, the css directory relative path should almost always be in the root directory of the site, so in your source code it should probably always be "/css".

I've been designing websites since late 1994, and I still use reference books; in fact I used one to verify this information before writing this reply.

So I'll stick to my recommendation. And I still don't think it's DA related; the same code and the same path would work with apache on any server, and even on Microsoft IIS.

Jeff
 
Thank you for putting up with me :)

Jeff,

I really appreciate your taking the time to respond and thank you for all your help -- even tho I'm looking in the wrong place ;)

I must still be doing something wrong, because I have tried "/css/style.css", "css/style.css", and "../css/style.css".
The first option (with the leading slash) did not work.
The second option (without the leading slash) only works if my html file is in the public_html dir and not in a subdir.
The third option (with ../) only works if the html file is in a subdir of public_html.

I can force it to work by placing all my html files either directly in the public_html directory (will eventually become very messy :( ) or in subdirs one level deep (but then do I have to redirect from the default domain location to mydomain.com/subdir/index.html?) I saw in another post in which you described a stub index.html or something.

I looked at your site as an example and it appears that all your pages are in the "root" public_html dir. Is that correct? I would like to keep my file structure flexible so that I can organize different types of pages in different directories instead of all grouped together and yet still have a standard, consistently referenced path to my styles. Maybe I could use symbolic links? But I don't know if that is possible in DA.

I will keep playing around with the path to my style sheets and images. Thanks for your initial help on that. But could you elaborate on the stub file idea as maybe that will also help me a bit?

Thanks so much! :D
Diane
 
You can put the full path www.whatever.com/css/file.css and it should work. the reason /home/....etc didnt work is because you dont see it that way from the web. Thats the directories based on the server, and unless you are accessing the files server side such as with php, you have no access to that from the web. The web can only see from your public_html folder and onward.
 
Re: Thank you for putting up with me :)

dhenry said:
I must still be doing something wrong, because I have tried "/css/style.css", "css/style.css", and "../css/style.css".
The first option (with the leading slash) did not work.
I don't know why that doesn't work; I'm not a css expert and at the moment I can't find my css book :( ; it's buried somewhere.
The second option (without the leading slash) only works if my html file is in the public_html dir and not in a subdir.
Which is exactly what we'd expect.
The third option (with ../) only works if the html file is in a subdir of public_html.
Which is also what we'd expect.

The key question is why the first option doesn't work, and I don't have the answer :( .
I can force it to work by placing all my html files either directly in the public_html directory (will eventually become very messy :( ) or in subdirs one level deep (but then do I have to redirect from the default domain location to mydomain.com/subdir/index.html?)
You shouldn't have to.
I saw in another post in which you described a stub index.html or something.
You can forget that :rolleyes: unless you're prepared to do the research yourself; I've only created "stub" index.html files as part of empty frames, and I know frames are no longer recommended. You can do the same thing with Permanent or Temporary Redirects, but I'm not prepared to write an html HowTo in this thread.
I looked at your site as an example and it appears that all your pages are in the "root" public_html dir. Is that correct?
That is correct.
I would like to keep my file structure flexible so that I can organize different types of pages in different directories instead of all grouped together and yet still have a standard, consistently referenced path to my styles.
I understand. I just found a reference in a very old book that says the css has to be on the same directory level as the html files that refer to it. If that's a limitation, then it is, and I'm still not sure why the first example won't work, especially since Chris's method works.
Maybe I could use symbolic links? But I don't know if that is possible in DA.
DA allows the use of symbolic links in every test I've done. I wouldn't use them unless absolutely necessary, they can easily add a level of confusion.
I will keep playing around with the path to my style sheets and images. Thanks for your initial help on that. But could you elaborate on the stub file idea as maybe that will also help me a bit?
As I wrote above, I only do it with empty frames, and I don't know how to do it any other way, so I suggest you either do some research yourself or abandon the idea. If I have some time I'll look into it further but I now recommend redirects in .htaccess files instead.

Jeff
 
Back
Top