I'm editing a file in a folder in my root directory.. here's a quick tree:
root
- images
- m
- - index.php
If I want to grab the images folder from index.php, how would I go about doing that? I've tried:
../images
I want to eliminate having to use my website URL.
you should use /images instead of ../images if you know the image directory is in the root. this will resolve to a directory named images in the root from any path.
eg if you are on page /pages/html/MyPage.html the path /images will still resolve to the images directory in root whereas ../images would resolve to /pages/images.
Related
Im trying to host a github live server for a project that right now has a "index.html" main folder with 4 files inside that main folder named "forgot-pass.html" "home.html" "sign-in.html" "sign-up.html"
I know to host on github your html needs to be a index.html but my question is can you have a folder named index.html with html files inside that folder and it still work? or how can i host on github if i have multiple html files named various things.
Yes you can have more html files in the same folder or subfolders, but it's mandatory to have the "index.html" file. Also I think you can make that folder but will not work (I don't know if it works or not, but give it a shot).
Its required to have a "index.html" file located in the root directory. As far as having a main FOLDER named index.html with files inside of that as-well, did not work for me. but i did not try to have a index.html file in the root directory on its own ALONG with a separate folder containing the rest of the html files. So i don't know if that works or not. i just put all the html files in the root directory and made sure to have one named "index.html"
While learning about paths I found out that "/" takes you to the root directory. I made .html and .css files in the same directory to test how it behaves for different paths. When linking the css file, href = "app.css" and href = "./app.css" both work fine but when I try href = "/app.css" it doesn't link. I know "/" is suposed to take you to the root directory and from what I understand the directory of the html file is the root directory. So why isn't the css file linking properly?
/ means the root of the current drive
./ means the current directory
../ means the parent of the current directory
No need to add the "/" or "./" because your app.css file is in your current directory.
I have a website:
www.mydomain.com/panel/abcde.html
I don't remember the difference between ./ and ../
./ is used to return in the first level?
Instead ../ is used to simulate all domain?
.../ exists?
I believe it is like this :
/ = root of the currently location
./ = current directory
../ = parent of current directory
Reference could be found here
/ is the root folder of the filesystem.
./ usually denotes the current folder that your program or script is in, usually the same one with the file you run.
../ denotes the folder above the current one.
.../ Does not exist. If you type that on terminal, it will throw error No such file or directory
I am using Yeoman to create a static website, which created a file structure like:
-app
index.html
-css
style.css
-js
script.js
Gruntfile.js
README.md
bower.json
package.json
I used filezilla to send this to my server (using bluehost) but nothing seems to be displaying? when I try to hit the website. (ex. whatever.com)
Is it because my 'index.html' lives inside the app directory? Should I only host my app diretory so 'index.html' is in the root directory?
I think you are on the right track with location of index.html but not quite. Your file structure should look like:
[document root]
index.html
- css (a directory of the root)
style.css
- js (also a directory of the root same as css)
script.js
Gruntfile.js
README.md
bower.json
package.json
Note in the above structure, there is no -app folder. You can test the above by using your web browser and pointing to http://yoursite.domain/app and see if that displays.
If that does not solve the issue, then you may be uploading to somewhere outside of the document root for your web server in which case you should find out where that is. Best place to ask about that would be on either https://serverfault.com/ or on https://superuser.com/. Good luck.
I'm confused as to when the following are used and what they mean, for example in the src attribute of an img tag.
I know / means 'current directory' and ../ means 'up one directory'
. Current Directory? <a href="." />
./ Current Directory <img src="./image.png" />
/ Root directory <img src="/image.png" />
../ Up one directory <img src="../image.png" />
What is the difference between ./image.png and /image.png
Updated: / means root directory of the site
/ means starting from the root directory. Whereas ./ is the current directory, though I'm not sure there's any need for it (unless you're planning on appending to a PATH in Linux systems... happy to be wrong about that one).
./image.png will grab image.png relative to your current location. Calling ./image.png on domain.tld/site/page.html will look for the image at domain.tld/site/image.png
/image.png will look for the image in the root of your site. domain.tld/image.png
You could also use things like ../images/image.png. If this was used on domain.tld/site/page.html, the browser would load the image from domain.tld/images/image.png
The / means the root directory. Use . For the current directory.