• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Appropriate Linking and Folder Structure in BC

Engaged ,
May 19, 2012 May 19, 2012

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":

  1. If you have img1.jpg inserted in the About.html, it will be <img src="../Assets/images/img1.jpg"
  2. If you have the image inserted in the index.html, it will be <img src="Assets/images/img1.jpg"
  3. In the CSS, if you have an image background, you will do, .class { background: url(../Assets/images/img2.jpg) no-repeat; }

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:

  1. <img src="/Assets/images/img1.jpg"
  2. .class { background: url(/Assets/images/img2.jpg) no-repeat ....; }

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?


TOPICS
Newbie Corner

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , May 20, 2012 May 20, 2012

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

Votes

Translate

Translate
Mentor ,
May 20, 2012 May 20, 2012

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 20, 2012 May 20, 2012

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 20, 2012 May 20, 2012

Copy link to clipboard

Copied

That's correct.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 21, 2012 May 21, 2012

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 21, 2012 May 21, 2012

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 21, 2012 May 21, 2012

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..." ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 21, 2012 May 21, 2012

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 22, 2012 May 22, 2012

Copy link to clipboard

Copied

HAHAHAHA, you're so funny.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 22, 2012 May 22, 2012

Copy link to clipboard

Copied

LATEST

There are a number of use cases around javascript, ajax for example.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines