I´m working in a local project (offline) and need show a txt file outside of directory of html. How implement the relative path?
main-app
|
|-core-app
|
|-logs
| |-log-file.txt
|
|-plugin
|-plugin-core
|-www
|-index.html
The file is on logs folder, I need show it in index.html. I try to use src="../../../logs/log-file.txt" but don't work. An example of the code in html:
<object type="text/plain" data="../../../logs/log-file.txt"></object>
relative to index.html I think that it should be : data="../../logs/log-file.txt". One less directory shift.
Just change the .txt file to a .html file, and add styling... It works just fine, just add a linkto it in index.html.
Related
I want the path to the file to look like this: "/assets/style/home.css"
But even though VSCode recognizes this path, and takes me there when I click it, the CSS doesn't appear on the page. It only appears when the path has the two dots: "../assets/style/home.css"
Any ideas on how can I fix this? This is what the entire path looks like:
It's like that with every single path I use in this project, actually. I have to use the two dots for everything.
The "../" means that it is to return a directory, as your HTML file is inside the PAGES directory it is necessary to use the "../".
To call the css file like this "/assets/style/home.css" you need to move the assets folder into the PAGES folder
The "../" before the file path is used to move up one directory level. It seems that the HTML file linking to the CSS file is in a subdirectory and the CSS file is in a directory one level up. If you want to use the path "/assets/style/home.css" the file should be in the same directory as the HTML file or a subdirectory of the HTML file.
You could also consider using absolute path instead of relative path, it would work regardless of where the HTML file is.
Upvote if it helps.
Your code should work if RANDOMWEBSITE is the root folder of the web server.
It will work in VSCode if you open the folder RANDOMWEBSITE, but perhaps your webserver is configured to use a different root folder above your directory.
For example the root folder might be html, and your website is at html/RANDOMWEBSITE/. In this case it would look for the css file in html/assets/style/home.css, rather than html/RANDOMWEBSITE/assets/style/home.css.
Check what the root folder of the webserver is set to and reconfigure, or alternativly remove the RANDOMWEBSITE folder from your folder tree and work within the existing root folder.
You have to do that because .html is isn't "in the same line" as css. You can imagine that it's something like a crossroad if turn right but then you realise that you want to go left firstly you have to go back and than you can turn left. If you want do do "/assets/etc" you need to move you .html file to "randomwebsite/.html"
I have a website and need to provide a relative path to a particular file from other html files within the website. However, the website also needs to run locally and so the links are not working.
For example, I have the following structure for my webpage:
\---home
| index.htm
|
+---folder1
| \---sub1
| file1.html
|
+---folder2
| \---sub2
| \---sub3
| file2.html
|
+---links |
**link.html**
I need to provide through a common link that gets embedded in the file1.html, file2.html, and the index.htm pages, a relative path to the link.html file.
I tried <a href="/links/link.htm"> and this works when my page it is hosted on a webserver, but when the page is run locally, the link resolves to C:\links\link.html. I need it to be where ever the index.html file is located. Like C:\home\link\links.html or C:\dir1\dir2\home\links\link.html
How do I provide a common link relative to the index.htm folder when running the webpage locally?
Thanks!
ken
Have not done it recently... but the idea is to use ../../folder123/file.html. Two dots is upper folder and one is current folder. For simple page it is possible to trace and correct the paths in every page (above example results to upperFolder/upperFolder/folder123/file.html) Not recomended for big projects.
When you add just slash at the begining it resolves to root. If there is dot or two dots then it is no longer root but relative path.
Better solution would be to get the address and manipulate the links with script but for simple pages using relative paths is perfect.
Guess it helps.
When I try to upload an image file form my computer in my html file it doesn't show up in browser. But if I link a image file from the web it works. I've copied the file path correctly and made sure the extensions were correct. Is it something wrong with the file itself?Code In Question
In the picture you've attached you're placing an absolute filepath inside src while it should be relative, considering the file might be in the same folder as the HTML, but not in the same user folder/operating system etc.
To fix your issue I have an example below.
Folder layout:
website
index.html
images
myimage.jpg
Referencing:
How to reference to myimage.jpg relatively is by putting images/myimage.jpg inside the src attribute. The way you're doing it is website/images/myimage.jpg, but another user might not have the website in a folder called website but website2 for example.
My files are set up like this:
Root
|
tours----------------about----------------gallery
| | |
tour1.html about.html gallery.html
I want to link the about.html page to the tour1.html page. Is this possible?
I've tried multiple things and I just can't figure it out. I know that if it were in the same folder I could use <a href="about.html"> and if it was in the root folder I could use <a href="..//about.html"> but neither of those are working.
When working with directories in a lot of places, such as some command line prompts (shells) and other applications, it's very useful to know that using / at the beginning of the the path will traverse to the home directory from any level, while ../ will traverse to the parent directory of the directory you're in.
For example, if I were creating a link from http://www.example.com/path/to/file.html to http://www.example.com I could simply use Home.
If I wanted to create a link from http://www.example.com/path/to/file.html to http://www.example.com/path/file.html I could use File or File.
Finally, if I wanted to create a link from http://www.example.com/path/to/file.html to http://www.example.com/file.html I could use either File or File.
So for your example you could use either <a href="/tours/tour1.html"> (starting from the root) or <a href="../tours/tour1.html"> (going up one folder and then down into the tours folder).
There are different methods
You could use ../ each time to go back one step in your directory and then target your file.
Or(if you are familiar with node/express or ejs templates) you could directly target /filename as you specified in your app.get("/filename",.....
Thank you everyone for the suggestions. I tried out an absolute path instead of a relative path and it worked, so I'm just going to work with that instead.
This is a very basic html question, but I can't seem to locate the answer.
I have a local file located here:
/Users/Me/Desktop/Main/June/foo.txt
In an .html document located within the /Main directory, I can link to the foo.txt file using the full path:
Full Path Link
I would like to use relative paths to link to foo.txt. Does anyone know how to create a relative path link to this foo.txt file?
I tried the code below and a number of similar permutations, but I can't seem to successfully write the relative path link for this local file.
Relative path Link
Remove the file:/// part to have just ../June/foo.txt.
This should help you out.
If you simply drag your file from the solution explorer into the razor/html page, it will create for you everything you need.