On your local machine it is probably not a good idea to use the root of your C: drive as your site root. You have a User folder, so keep your files in that folder. Your User can be logged in with a limited use account and still have full read/write access to that folder. This is the recommended configuration.
Now given that, it makes sense to isolate your code projects from the other content of your User folder. Give it a parent folder, and then give each project, or site its own folder. Inside that have the index.html page which will be the home page of that site.
Files in that folder are relative to the home page. ./ says, āsame folderā. Thatās Linux, not Windows, but is should still work in Windows. If about.html is in the same folder, then <a href="about.html">About</a> will work as expected if that link is in the index page. It is relative to the requesting page.
/ says, Volume Root on your local machine. It is off the table. Never use that at the start of a URL within your site navigation, that is until it is mounted on a web server. Then it will be your Site Root.
so when do I use ./ or / with my webpage? Can I put different web pages in different folder or it has to be in the same folder for that specific website?
I used the format on Linux <a href="./index.html">webpage</a> and it worked! But when I tried <a href="./index.html">webpage</a> it did not work for some reason.
On your local machine, the latter, never. The former is okay, but it can also be ignored. Itās a Linux thing. For now, it is okay to ignore it. Stick to relative paths.
(When I posted this, the pathways all had three ellipses (ā¦) before the slashes instead of the two that I wrote. I donāt know why the website is changing it, but they are all only supposed to have two dots and a slash.
Iām 76 years old and just getting into coding after varied careers in Electronic Engineering, Quality Assurance, Law Enforcement and University Financial Aid, among others. Iām really enjoying the course, but had a bit of trouble wrapping my head around the hierarchy of file storage and retrieval. Finally saw your response here and it made sense. I had my program file in the Desktop/Coding Projects/Test Project folder and my original image (photograph) file in my C:\Users\timot\OneDrive\Desktop\PHOTOS folder and LISTED THAT as the original path, which worked. Then I saw your file accessibility explanation, so I moved the photo into the same folder as my project file and used <img=āphoto name.jpgā/> and it worked. Then I moved the photo up one folder and tried <img="ā¦/photo name.jpg"/> and it still worked. Moved the photo onto the desktop and tried <img="ā¦/ā¦/photo name.jpg"/> and . . . still working. Finally moved the photo back into my PHOTOS folder on the desktop and routed it <img="ā¦/ā¦/PHOTOS/photo name.jpg"/> and, of course, it still works great. Trying out all these variations helped me understand how the file system works and how to refer to the different possible pathways. Thanks so much for your time and effort and your brilliant explanations!
The forum software interprets two dots as an ellipsis. To get around that, be sure to wrap code fragments in single back ticks for inline, and triple back ticks for sample code blocks.
We can also indent by four spaces to render a line of code.
<img src="../images/photo.jpg" alt="">
Search for āhow to format code in postsā and experiment with the various techniques given in that article. It is a way to preserve our original code layout and make it readable as code (or markup).
Now my questions is when writing out absolute paths. Do I need to create a folder for them? If so, how would I know how to write out the folder / file name?
mtf
you are a wonderful moderator. 70s 80s dos 2.0, unix, dbase, they all had there slashes in different directions, foreword for this, back slash for that. Ego kept everyone from agreeing on a simple thing like which way to go forward or backward for root directory. 1 dot 2 dot and away we go. Thank you for your clear answers.
Reading this ( not even having to do it ) also gave me simpler insight as to how multiple dots can be use to find a certain file located further away so TYVM ofc ill find out later what the reasons would be to place a file so far away or the benefits to creating a ā¦ path, probably something beneficial to multi links or folders. My mind wonders now for example to one link opening two new and different webpages And like others mention its rlly helpfull to read trough the questions section and learn some details it saves alot of time on experimenting myself too seeing as im on a reasonable fast time scedual. Excuse me to those that prefer to see perfect english spelling.
Also, keep in mind the starting point of our file paths. It really helps to understand this tiny detail. If we have two HTML files in one directory, paths for both of them would start from where they exist in the directory. Kind of like the maze game or a treasure map
I donāt know every tech aspect but Iāve seen that we can use the necessary root without ā./ā You need to write just the name of your HTML document. For example, (I wrote it without angle brackets on both sides to may to see it so just add them if you need it ^_^)
a href=āThe_1st_Codecadamy_website_from_the_course.htmlā target=ā_blankā>My first website on Codecadamy</a
Iāve put it on https://validator.w3.org and it hasnāt found any mistakes.