Results 1 to 9 of 9

Thread: Absolute or relative paths?

  1. #1
    Join Date
    Oct 2010

    Absolute or relative paths?

    For many links between pages on the same folder level, I use relative paths (like home/products/contact, etc.).

    Once you move to a deeper level, of course, those links need to be adjusted. One way of dealing with this would be to change all the links to absolute paths (http://www...). Then I could just reuse the same code on all folder levels.

    I'm just curious to know if there is any speed penalty of using one way over the other.


  2. #2
    Join Date
    Nov 2006
    Springfield, MO
    If you use http://www. then if your domain name changes, you're hosed. I'd just site-root relative:

    Ryan Butler

    Ryan Butler.org

  3. #3
    Join Date
    Mar 2011
    The speed difference between relative and absolute paths is negligible - especially when considered among all of the other factors that go into how a web page is loaded.

    My main concern with relative links/paths is potential search engine issues. You can run into what are called "canonicalization" issues when search engines start to crawl your site with and without the "www." subdomain prefix or the "https://" protocol and they start to "discover" duplicates of all of your pages. Dynamically-generated sites can also lead search engines into unending mazes of nested psuedo-directories that can be a problem. Then there are the rogue sites out there that copy your content. If you use absolute addressing for navigation, you stand a better chance of the links on those copies sending users (and search engines) back to your site instead of deeper into the thief's site.

    These problems are generally easy to repair if you know what you're doing, but it can take many weeks to recover. And when it's your site (or income!) that is affected, that can feel like a very long time. So, although I don't want to exaggerate the potential problems involved, I tend to be religious about using absolute addressing for navigation, especially to the home page, for all of the sites I manage.
    Rick Trethewey
    Rainbo Design

  4. #4
    Join Date
    Oct 2010
    Thank you Ryan and Rick for your thoughts!

    @Rick - a whole new way of looking at things. My sites aren't dynamically generated, just plain HTML, so some of the stuff you mentioned may not apply, but it sure is interesting (and scary to boot!).


  5. #5
    Join Date
    Oct 2010
    Quote Originally Posted by ryanbutler View Post
    If you use http://www. then if your domain name changes, you're hosed. I'd just site-root relative:

    Hmm, beginning with a / does not seems to get me to the root level.

    By way of example, the index page in my root level uses an image from a folder with images, like this:
    <img src="images/logo.png">

    There is also a directory with products where each product has its own folder, so the index page of a product is 2 levels down from the root level:

    root > products > product_a > index.html

    To use the same image, so far I used:
    <img src="../../images/logo.png">

    <img src="/images/logo.png">
    as I understand your suggestion, doesn't work.

    Can I somehow use a single relative definition of the path? I know that absolute will work, it's just cumbersome to edit offline.


  6. #6
    Join Date
    Mar 2011
    The root-relative path won't be the same on your computer as it would be on your website (which would resolve to something like "C:/..."). So, as long as you intend to develop locally, I wouldn't recommend using it on external resources like images or stylesheets. Stick to using simple relative paths.
    Rick Trethewey
    Rainbo Design

  7. #7
    Join Date
    Oct 2010
    Oh you are saying that the root relative path method above won't work in offline mode but will work once the page is hosted. Excellent... I get it.


  8. #8
    Join Date
    Aug 2013
    There is no speed penality but it is fine to use relative path. Absolute path usually change when site is shifted or you add some plugin like it often happens with me in wordpress.

  9. #9
    Join Date
    Oct 2010
    Yes, I 'm quite happy with Rick's suggestion. I'm fine with busted layouts while offline and checking online every now and again while developing.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.10154 seconds
  • Memory Usage 2,923KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (9)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates