SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Design Question

  1. #1
    SitePoint Zealot
    Join Date
    Apr 2011
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Design Question

    Come to think of it.. it is not a design question as much as format..

    Pretty basic question.
    I have my folder on my web server, where my index.html is located (named A), and then I have a subfolder for a php file I was making (named B).

    Now normally when you are in A and you want to link to something like your photos which are located in another folder (named C) you would say: FolderC/image.jpg... say i am in folder B (which remember is a sub-folder of A), how do I link back to it? Would I do FolderA/item?

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2011
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out btw.. it is, ../filename

  3. #3
    SitePoint Zealot zbing's Avatar
    Join Date
    Jun 2002
    Location
    Lisbon, Portugal
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup!
    zbing

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    39,809
    Mentioned
    158 Post(s)
    Tagged
    4 Thread(s)
    Glad you figured it out and you can find more info here.

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just make sure you don't end up with links like <a href="http://www.sitepoint.com/forums/resource/"></a> as this leads to bad coding practices. The only time I reference a ../ would be when using PHP includes, never in a website structure (search engines can have issues with this).
    Daryl Quenet, Web Developer / SEO Consultant
    Web Design Canada, Link Building 101, Dr MadCow's Web Portal

  6. #6
    SitePoint Enthusiast PiontekMedia's Avatar
    Join Date
    May 2011
    Location
    Vermont
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have also used the ../ to get to the root directory in CSS when referencing and image.

  7. #7
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would never reference the root in CSS that way. ALWAYS reference the root as an absolute URL starting with a /images_directory/file.jpg. One other problem with using ../ is if you every implement things like mod rewrites this can cause a debugging nightmare.
    Daryl Quenet, Web Developer / SEO Consultant
    Web Design Canada, Link Building 101, Dr MadCow's Web Portal

  8. #8
    SitePoint Addict EarlyOut's Avatar
    Join Date
    Mar 2011
    Location
    Sector R
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by drmadcow View Post
    I would never reference the root in CSS that way.
    Sometimes you don't have any choice. I do development in an application that produces multi-directory photo album pages. But within a given album, there's typically just one CSS file, at the album's root level. The application has absolutely no idea where you're going to host that album. So, it doesn't know what the absolute URL for the CSS file will be, nor can it count on the album residing at the root level of your hosting account (you might plant it at http://www.example.com/personal/travels/myalbum). So, references to the CSS file might be ../../../styles.css (at a third-level subdirectory, for example, like myalbum/europe/italy/2009). A relative URL is the only way to keep the entire album "portable," i.e., it can be hosted anywhere.

    A properly-formed mod rewrite shouldn't have any problems with this, but yes, if you get careless, weird things could happen!

  9. #9
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I always try to keep all my CSS in one central directory at a fixed location off of the root of the website, if I had a scenario with multiple css sheets for each album I'd keep them in the same sub directory off of the CSS directory.
    Daryl Quenet, Web Developer / SEO Consultant
    Web Design Canada, Link Building 101, Dr MadCow's Web Portal

  10. #10
    SitePoint Addict EarlyOut's Avatar
    Join Date
    Mar 2011
    Location
    Sector R
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To repeat, this is an application that's running on your PC/Mac, and building the pages in a certain structure. It has no idea where the end product is going to land. It can't refer to some "central directory," about which it knows nothing. It knows only about what it is creating, and it must use relative URL's to do that.

  11. #11
    Mouse catcher silver trophy
    Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,830
    Mentioned
    111 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by drmadcow View Post
    Just make sure you don't end up with links like <a href="http://www.sitepoint.com/forums/resource/"></a> as this leads to bad coding practices. The only time I reference a ../ would be when using PHP includes, never in a website structure (search engines can have issues with this).
    (Unfortunately it looks like VBulletin has stuffed up the example link you gave in that "trying to be helpful but failing" technique it uses so often. But I think we've got the picture of what you meant from the rest of the text)

    I don't see why it leads to bad coding practices. Sometimes you will have a folder structure that is several layers deep. Depending on the nature of your site, it may be much easier to manage it if you store things in that way than having fewer folders but each having many more pages in. So sometimes a link to ../ may not be a link to the root, it may be a link to the parent folder - in which case, I'd say it is better to retain it as ../ rather than give a root reference that then has to include the folder name. If you do it that way, your code is less flexible and less reusable, you're more likely to end up with a link to the wrong folder at the next level up.

    As for search engines - nope. Search engines, like any other browser with a person using it, can and will correctly and unambiguously parse any correctly formed hyperlink, whether it's a relative reference, a root reference or an absolute reference. Search engines don't have any problems coping with relative links incorporating ../

  12. #12
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,048
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    In the case of well developed software its all irrelevant since all request are normally routed through a single entry point using GET parameters to determine the content that will be shown.
    The only code I hate more than my own is everyone else's.

  13. #13
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Stevie oddz said it right with the word well developed. But not everyone develops at a high level. When I was the Director of SEO Services of Beanstalk SEO I analyzed hundreds of websites and I couldn't the number of times people used the ../ references wrong. Personally I don't use them at all to avoid potential issues.
    Daryl Quenet, Web Developer / SEO Consultant
    Web Design Canada, Link Building 101, Dr MadCow's Web Portal


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •