+2

Relative path against a folder

Matteo Del Vecchio 14 years ago updated by Gregory Potter 1 day ago 4
When I use HTML and CSS files, I have to rewrite every path that is in code. Why don't you make every path relative to its super directory? That's what I mean: in the Files view, I create a new folder called Project, where I put every file that belongs to that project. Inside it I create and index.html file and a folder called "images". Now when I write the code I would like that paths should be written as /images/image.png instead of adding even the main folder name like /Projects/images/image.png
This would improve the user experience, I think.
+1
You can do that: just write images/image.png - you need to leave out the first slash. The slash would tell it to look at the root directory - just like on a real web server.
+1
See also http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm

  • links in the same directory as the page have no path information listed: filename
  • sub-directories are listed without any preceding slashes: directory/filename
  • links up one directory are listed as: ../filename

Thank you so much Alexander... I didn't remember these things :) I'm really sorry and thank you so much for this fantastic application! ;)

The architectures I work with heavily favor root-relative paths for the majority of things, so it would be very nice if there was a way for us to specify the root directory for the local server for the preview, so that if we want to use root-relative paths we don’t have to manually update them on every file or use a build tool to correct them before deploying.

The ideal implementation of that for me would look something like a toggle in the Web Preview settings to have the root set (on preview launch) to the highest ancestor directory that contains an index.html, or something like that.