Copy link to clipboard
Copied
This might be an outdated question but I think if it is answered, it will help all newbies to BC. Not that I have an issue, but I just want to re-confirm something avoiding any broken links in the future by surprise.
I explained this in the basic manner possible so we're clear about what we talk about. There is a question though in the end.
Let's take a basic site structure:
Root Folder
(All BC Folders - let's not worry about those now)
index.html
Assets [Directory]
images [Directory]
img1.jpg
img2.jpg
stylesheets [Directory]
mystylesheet.css
Information [Directory]
About.html
Now in the usual way we learnt "old school":
NOTICE THE "../" before "Assets" to browse a directory back.
------------------------------
Situation:
In Dreamweaver, these paths work just fine obviously and so in BC, except that in BC you can also link as follows:
NOW NOTICE THAT THE ".." before the slashe is not there. And for the index.html, we'll add the slash.
This is still working fine somehow.
But the question is, are those both methods work with BC? or is there something we need to know about?
Hi there,
The best practice is to always denote root folder (/) in your paths. If you use a path without / e.g. Assets/images/img2.jpg, the browser will be able to find that image if you're at somedomain.com/index.html, but if you're at somedomain.com/somefolder/index.html, the browser will look for Assets folder, inside the current folder instead of starting from the root.
I hope that helps!
-mario
Copy link to clipboard
Copied
Hi there,
The best practice is to always denote root folder (/) in your paths. If you use a path without / e.g. Assets/images/img2.jpg, the browser will be able to find that image if you're at somedomain.com/index.html, but if you're at somedomain.com/somefolder/index.html, the browser will look for Assets folder, inside the current folder instead of starting from the root.
I hope that helps!
-mario
Copy link to clipboard
Copied
Which means, in a sub page in this case "somedomain.com/somefolder/index.html" you'll have to point to "../Assets" right?
Copy link to clipboard
Copied
That's correct.
Copy link to clipboard
Copied
Hi Mario, I thought I sounded like a beginner in my last question but I'm not.
The reason I asked this question because I can confirm that my theory is true.
So here it goes:
I have index.html in the root folder as well as a stylesheet folder which has the modulestylesheet.css and global.css
in the global.css I have 2 classes, each with a different background image, and the first one's url is pointing to (../Assets/images/image1.jpg) and the second class is pointing to (/Assets/images/image2.jpg)
The weird thing is (which made me start this discussion in the first place) is that both of them work, even after clearing the cache, reloading and resetting the browser. Where in a typical hosting account, it will definitely break. Even in Dreamweaver it's breaking.
I'm a guy who is a bit funny to know why and how everything works (which I think is part of someone cursed with quality control).
This is why I needed some clarification on how this can be still possible, what is BC's logic behind this. I just don't like surprises in the future.
Thank you
Copy link to clipboard
Copied
Does not work in all cases though so do not break the convention of how BC has been implemented.
With a CMS true functioanlity targeting of files often will require you to place a system code tag or say php code tag with the CMS to insert the root/template location of the site.
BC implemented the great easy system of / as the means to read from the root.
It is pretty simple, it works very well, covers every aspect from web apps, sub folders, css... so it is good to keep to this and cosistancy as even if BC make infustructure changes this will continue to work, other path formats may change if they modify further the internal system file handing structure which for example when Liquid becomes availible has layotus under _system for example. Does not effect this of course but just an example of how BC can change system structures at any time.
Copy link to clipboard
Copied
Liam, I appreciate when you help everyone everyday from your own personal time, but a question: Why do you love to play mysterious sometimes
Anyway, what is that "Does not work in all cases?"
Are you suggesting that no matter where is the file located, we can always point to elements using "/Folder..." ?
Copy link to clipboard
Copied
I like people to figure it out for themselves and learn the system, HTML, Javascript etc and I know that annoys people sometimes but not going to change because people actually do learn if they get the old brain working for a few mins
To your latter part, yes, because it's BC's impelemntation for root access rather then making you use a tag all the time, it is very elleggant and wont be effect by any file management or structure changes unless massivly drastic.
Copy link to clipboard
Copied
HAHAHAHA, you're so funny.
Copy link to clipboard
Copied
There are a number of use cases around javascript, ajax for example.