Lightbox 2.05 - PATHS - GETTING THEM RIGHT
LinkBack: Lokesh's LightBox Forum
LinkBack: Original Lightbox2 Project
LinkBack: Lightbox Setup Instructions - More Explicit (Hopefully More Helpful)
PATHS - GETTING THEM RIGHT.
Pathway problems account for about 95%++ of the problems people wrestle with when deploying lightbox. This is because these people are unfamiliar with html coding basics.
If you are having problems with anything, check your pathway issues first...
- did you put the required LINK and SCRIPT codes in the HEAD section of your page(s)? (check the instructions)
- are the paths correct?
- are you following strict capitalization? and
- are the files actually deployed?
There are 3 kinds of paths used for linking...
- Absolute
- Document-Relative
- Root-Relative
***ROOT-RELATIVE PATHS are EASIEST to USE in Local Site Links (href=, src=, etc) because they allow the greatest flexibility, will allow a tag to work in pages anywhere on your site without requiring editing the path. They also incur less work for the server in large sites.
ABSOLUTE PATHS are considered Equally as good, if not better, while not being quite as easy to manage.
DOCUMENT-RELATIVE PATHS should be avoided wherever possible. They are tough to manage, break easily, and incur more overhead on the server in large site deployments. Use these as a last resort.
•
ABSOLUTE Path: usually uses "http://--" to explicitly point to website pages. Pages may be inside or outside of your website.
Example:
http://www.mysite.com/index.html means GoTo mysite.com and find "index.html" right there at the Root Directory of that site.
Example:
http://www.mysite.com/folder1/gallery.html means GoTo mysite.com and find a directory (off the Root) named "folder1", and in there find a file named "gallery.html".
NOTE: There are
Pros and Cons of Using Absolute Paths for linking to files within the same domain.
•
DOCUMENT-RELATIVE Path: relies on what is known as "RECURSIVE LOOKUP". It uses directions From the
source page To the
destination page, sort of like saying "Start here then follow this path until you reach the destination". The
recursive part of the pathway designation is "../". It says "recurse one directory", ...meaning "look back one directory" or "look up one directory"... or "look behind one directory"
So Say you have
- a file located at www.mysite.com/folder1/subfolderA/sourcefile.html
- keeping in mind the file sourcefile.html resides in the directory/folder named "subfolderA"
- with links in it like so:
Example: href="
../index.html" means Go Up One Directory
(../), then Find index.html there. This would be looking in the folder1/ directory for a file named index.html
Example:
../../folder3/gallery.html means Go Up Two Directories
(../../) (in this case, this will go look in the Root Directory), then Find a directory named "folder3", then go into it and Find a file named "gallery.html" there. This assumes there is a folder created at the root of the site named "folder3"
NOTE HOW... if you were to move the source page to a different folder level on the website, all the links using Document-Relative pathway assignments would break! So you cannot simply copy links from one page to another at a different level. Managing a complex website in this way is impractical.
•
ROOT-RELATIVE Path: Site-root-relative links use a single forward-slash
"/" at the beginning to signify
- the ROOT DIRECTORY (the primary directory where you begin putting files and folders for your website),
- AND the instruction: "Start at the "document root" of the site (this website's root directory) and navigate down the directory path directly from there."
Example:
/index.html means GoTo the Root Directory (first "/") of this website (this domain) and look for a file named "index.html".
Example:
/folder3/gallery.html means GoTo the Root Directory (first "/") and look for a directory named "folder3" ("folder3/"), and in there look for a file named "gallery.html" ("gallery.html").
NOTE HOW... if you were to move the source page to a different folder level on the website, all links would continue to work as usual, because Pathways remain constant no matter where you place the source file.
MORE DOCUMENT-RELATIVE EXAMPLES
There are three ways Document-Relative pathways are designated- the method you use will depend on the location of the source and destination pages in relation to each other. We will use the example on the right and create hyperlinks from the page called sourcepage.html to other pages in the site "mysite.com", whose home, or root, directory is "public_html".
"sourcepage.html" resides in the folder named "article1" at "mysties.com/zarticles/article1/sourcepage.html"
(1) If the destination page is in the same directory as the source page
All you need to specify is the source file name:
<a href="introCh1.html">Go To Intro to Chapter 1</a>
(2) If the destination page is in a folder inside the source page's folder
Specify the folder name and then the file name:
<a href="chapter1/page1.html">Go To Chapter 1</a>
(3) If the destination page is in a folder outside the source page's folder
Use the special instruction ../ which signifies "one directory higher".
The following link means "Go Up one directory level (in this case- to the"zarticles" folder), then go to a folder called article2, then to a file called introCh2.html":
<a href="../article2/introCh2.html">Go To Intro to Chapter 2 </a>
You can repeat the ../ to make the link more than one level higher, for example, "Go up two levels, to a file called index.html" (which in this case just happens to be in the Root Directory of the Site [public_html])::
<a href="../../index.html">Go To The Home Page</a>
Important Note: For relative links to work, you must keep the file structure intact. For example, if you moved the sourcepage.html file down into the chapter1 folder, the relative links would no longer work. In this case you would need to add another ../ to point the links to the correct level. For example:
<a href="../../../index.html">Go To The Home Page</a>
(4) Here's how url(path/to/lbimages) would look in lightbox.css
url(../images/lbimages/nextlabel.gif)
(5) Here's how path to loading.gif would look in lightbox.js
fileLoadingImage: '../images/lbimages/loading.gif',
(6) Here's how LINK Tag would look in sourcepage.html
<link rel="stylesheet" href="../../css/lightbox.css" type="text/css" media="screen" />
(7) Here's how SCRIPT Tag path would look in sourcepage.html
<script type="text/javascript" src="../../js/prototype.js"></script>
MORE ROOT-RELATIVE EXAMPLES
(1-3) Here are how the paths to all those same files appear using Root-Relative paths...
<a href="/zarticles/article1/introCh1.html">Go To Intro to Chapter 1</a>
<a href="/zarticles/article2/introCh2.html">Go To Intro to Chapter 2</a>
<a href="/index.html">Go To The Home Page</a>
(4) Here's how url(path/to/lbimages) would look in lightbox.css
url(/images/lbimages/nextlabel.gif)
(5) Here's how path to loading.gif would look in lightbox.js
fileLoadingImage: '/images/lbimages/loading.gif',
(6) Here's how LINK Tag would look in sourcepage.html
<link rel="stylesheet" href="/css/lightbox.css" type="text/css" media="screen" />
(7) Here's how SCRIPT Tag path would look in sourcepage.html
<script type="text/javascript" src="/js/prototype.js"></script>
This is "set it and forget it" type of linking. You can create a link and use it anywhere on your site without needing to edit it. You can move a page without having to edit/update the links. You can test your site locally as well as live with consistent behavior.
NOTE: Pros and Cons of Using Absolute Paths for linking to files within the same domain,
1) If you move your domain or your pages, links will have to be edited (sitewide).
2) Relative URLs carry the same effectiveness as absolute URLs, and vice-versa. There is no difference regarding their impact with SEO;
HOWEVER, the general consensus (2011) suggests that absolute URLs are the accepted practice for SEO in place of relative links primarily on the basis that it is better to be safe than sorry...
Relative URLs run the risk of becoming incomplete links:
- when employing code that may compromise the integrity of a link (where the consistent performance of a link may come into question, say, due to some sort of scripting you are using, etc), you may need to employ Absolute URLs
- Site Scraping is one reason some choose to stick with Absolute Linking ..."at least there is a link back to my site if my site gets scraped"...
- Google and other Search Engine Crawlers can experience problems...
***Personally I find using Absolute Linking an unnecessary pain and nuisance, and only employ its use where I find it necessary.
If you do opt for a Root-Relative URL setup, then you should consider implementing a Base tag into the page headers of your website. For example:
<base href=”http://www.mydomain.com” />
This can help safeguard against any of the potential worries mentioned above while allowing you relative-linking freedom.
To learn more about that, point your search engine at: html base tag
KEEP IN MIND: There are some cases where it may be desirable or necessary to use Absolute Paths... for instance, when feeding certain types of pages to certain mobile devices it may become necessary to use Absolute Paths to ensure consistent access to the pages at your domain. I.e., it can happen that in some cases Relative Linking will lose the 'implied' domain.com root reference, and the link(s) will not lead back to your website.