How do you apply relative paths for locally developed HTML files - path

I know the subject line must sound really stupid. Of course you would locally develop HTML files - didn't know how to phrase it better since I'm a beginner at HTML+CSS.
So to get to the point:
I'm linking to images and pages on the HTML file I'm editing. However, when I open the HTML file in my browser locally the links are broken because I'm not using an absolute path. My preference is to use relative path because I'll be able to simply move my project file folder onto my server without having to change the URL paths in my HTML files.
My question is: How do I get the relative paths to point to where I want without having to list the entire drive directory?
Ex. My local HTML has the following line:
<img src="/images/logo.jpg">
But opening the local HTML file in my browser, the image is broken since it points to: file:///D:/images/logo.jpg
How do I get it to point to {local root}/images/logo.jpg instead?

What I did was to install a local development server such as EasyPHP, and setting the proper root folder within my project folder. Setting the root folder tells the local server where the root is, and so any relative paths work as expected.

Related

Hyperlink to a file in the current folder regardless of its location on the drive

Putting together a .doc file with a table of content with links to external files. The challenge is: how to make them so that it points to the given file in the current folder regardless of its location on the disk.
Context: I will be sending the set of files to another person, so I can't put the path on my machine, nor on a server since they will be working offline. They will be working on Remarkable device and I want them to be able to use the major overview file with the links to access each of the files, rather than having to browse the folders.

How to make Ctrl-click work in Visual Studio Code when paths in source code don't match paths in filesystem?

My access to the filesystem for our web server starts one folder deeper than the web server's root. So relative paths in our HTML look like this, for example:
<link href="/division/css/style.css" rel="stylesheet" />
But the path to that same file in my filesystem is:
s:\css\style.css
So whenever I CTRL-click on something in the editor I get an error because VScode is trying to open:
s:\division\css\style.css
But that doesn't exist. EDIT 1: my path does not include \division
I feel like I'm missing something obvious, but I've googled for hours and haven't found a solution to resolve this, such as a filter that strips "\division" from the filesystem paths or a mapping setting that tells VScode that relative path "/division" exists at S:.
EDIT 2: The division folder exists in the root of the share, and you can't map a drive to the root of a share ( \\server\, while allowed in explorer, isn't allowed in drive mappings). Neither would VScode allow me to open \\server\ as a folder. I tried creating a folder placeholder folder on my local drive containing another folder called division with a symlink inside that to \\server\division, while this looked like it worked in VScode, CTRL-Clicking on a link wouldn't work, it says the file doesn't exist. It looked like it wouldn't follow symlinks.

Absolute path for img and js excluding project folder name Visual Web Dev

I've this little but annoying issue in my project in Visual Web Developer 2010 Express. I'm developing a website with .aspx files located in a large folder structure i.e. www.domain.com/group1/type1/somefile.aspx, the root folder contains a "styles" (for css), "images" and "js" (for javascripts) folder. I've read a lot about base tag, absolute and relative path today. Finally I realized "absolute path" is the best choice for me.
The main problem is that when I preview (locally) my site in browser the absolute links for image, css, and js are not working, I'm using src="/js/gl.jquery.js" which I believe is correct and will work online.
The source code of the page for the javascript says http://localhost:61700/js/gl.jquery.js, when I switch to relative path script src="../../../js/gl.jquery.js" and preview the website, it works fine, and the source code for the javascript path says http://localhost:61700/ProjectName/js/gl.jquery.js (Notice Visual Studio added the ProjectName in the path) So I'm taking my guess that when the project goes online (on a main domain) it will work correctly, but right now I need to keep developing locally without this issue. Is there a way to fix this in Visual Web Developer? maybe some tag for the web.config file that I can remove when goes online, or some website property?
I know a quick solution will be develop with the relative path, and modify the code when goes online to absolute path, but I'm looking for some cleaner method, as aditional information I didn't choose base tag because I read cause troubles with anchors links (href=xx.html#question3) and I need to use them at some big files. And avoid the relative path because it's possible that the company ask me to move some files in the future and I don't wanna be updating relative paths.
Thanks a Lot!
Problem solved! This is the solution I found Thanks to ScottGu's Blog.
I quote the main thing:
when opened a web-site and run the project, VWD launch and run the built-in web-server using a virtual app path that equals the project’s root directory name. For example: if you have a project named “Foo”, it will launch and run in the built-in web-server as http://localhost:1234/Foo/Default.aspx.
One downside to this is that it makes it hard to fully qualify things like static CSS and image files within your site (for example: using root qualified paths like /images/myphoto.jpg or /css/mycss.css). Note that you can use the “~” app path trick for dynamic resources – but static resources still end up being a pain (js, css, images files.) (This was my issue)
Here is the guy entire post: Click Here
Here is the main solution:
1) Using the solution explorer within Visual Studio, select the web-site project node, (the one with the World icon)
2) There is a properties named "Virtual path" at the bottom. Change the "virtual path" setting it to / to run as a root web-site.
And that's it, setting up the / I can manage my files easily.

Fitnesse: Open file relative to current page

Is there a simple way to open a file from within a fixture, using a path relative to the current wiki page? The files are actually being stored in the same directory as the wiki page.
I'm using those files to store some expected data, that is later compared to the data actually measured while executing a test. Embedding the data in the wiki page would simply be too much.
I've already spent quite some time searching through the API, but couldn't find anything except how to access files in Fitness' root folder.
It would be simpler to store the files somewhere relative to the FitNesse root and put the relative path on the wiki page
|calculate some results|
|compare to expected at|relativepath|
To create/access pages path relative to the current wiki page use this syntax:
>RelativePage
> makes path relative from current page.

why have most of the files in a dreamweaver site been put into a directory called 'upload'?

I cleaned up someone's style sheet for a Dreamweaver site, by editing the css directly, and now the secretary is having trouble using her old template.
Most of the files in her site reside in subdirectories of the 'upload' directory. For example, I would have expected to see the stylesheet in
../assets/css/ etc.
but in fact I'm finding it in
../upload/assets/css/ etc.
In addition to assets, I am also finding Templates and images as subdirectories of 'upload'.
Do you know why this 'upload' directory was used?
I am considering two possible approaches.
(1) Make sure everything needed is in ../upload/ and remove the subdirectories that are directly in the root directory
(2) Edit the template to remove all references to ../upload/
Note that (2) appeals to me because the file structure will be simpler; but I wonder if the client has some sort of extension in her Dreamweaver that causes everything she ftp's to be put into the 'upload' directory.
Note that so far I have copied my cleaned up css file over to ../upload/assets/ as a short-term solution. But they want to be able to make changes to their template, and add new pages, on their own in future.
Thanks.
The likely problem is how she has her FTP remote settings specified. It appears that it now points to the upload folder rather than the web root. Or, it could be that her FTP user account is tied to the upload folder rather than the web root.

Resources