View Full Version : How to link to local files.
effpeetee
08-08-2008, 06:49 PM
<p class="right">
<a href="#section1">Harvest Light.</a> -
<a href="#section2">Light</a> -
<a href="#section3">Now no condemnation.</a> -
<a href="#section4">People are the Harvest.</a> -
<a href="#section5">Personal Testimony.</a> -
<a href="#section6">Accept Jesus.</a> -
<a href="#section7">Buy the booklet.</a> -
<a href="#section8">Write the Vision.</a> -
<a href="#section9">Contents of booklet.</a>-
<a href="#top">This page</a></p>
This piece of code links to places on the page.
How do I modify it to link to local files. That is files in my "MySite" directory."
I have fiddled with it but to no avail. I tried removing the # and also tried a base address.
It's just not my day today.
Frank
rmedek
08-08-2008, 08:03 PM
Do you mean a site, online, on the internet, that links to a file you have on your local computer?
effpeetee
08-08-2008, 08:18 PM
Do you mean a site, online, on the internet, that links to a file you have on your local computer?
Both actually. I can't really put it online until it does link locally.. I am puzzled. I have not had trouble previously. It must be something basic I think. Is it the # sign. I removed it but to no avail. I have files Page1 through to Page 5 on my PC all in the root folder. Everything that I have webwise is in the same place. Not even any sub-folders.
Is the code I gave valid? If it is, I'll have to look carefully locally. I am tired and may be missing something.
Frank
Corwin
08-08-2008, 08:37 PM
if i understand right and you are trying to link files in the same directory, here is how i would do it:
instead of #section1 use /pagename.extension
so if you want t link to page1.html in the same fodler/directory it would be : /page1.html
in your code:
<p class="right">
<a href="/section1.html">Harvest Light.</a> -
<a href="/section2.html">Light</a> -
<a href="/section3.html">Now no condemnation.</a> -
of course if your files are not html extension then you would replace that with the proper one :)
rmedek
08-08-2008, 08:58 PM
"#something" links to an area on the same webpage with an id or name of "something".
"/directory/file.txt" will link to the root of your website, then look for a folder called "directory," then in that folder look for a file called "file.txt".
If you don't have any subfolders, and you need to link to a file in the same directory (folder) as the webpage, then I would use relative paths:
<a href="file.txt"> looks for a file called "file.txt" in the same directory as the webpage you are on.
<a href="test/file.txt"> looks for a folder called "test" in the same directory as the current webpage you are on, then looks for a file called "file.txt".
<a href="../file.txt"> goes up a directory, then looks for a file called "file.txt".
The problem with using "/something" in a link if you are developing on your local computer is that unless you have a local webserver set up, the root directory isn't "http://yourwebsite.local" or whatever but rather "/Users/rmedek/public/dev/sites/yourwebsite/public_html/" or whatever the equivalent is on your computer. That is—the root directory isn't your main website directory but rather the hard drive on your PC.
ninnypants
08-08-2008, 09:18 PM
Is this something like what you're looking for?
<p class="right">
<a href="harvestlight.html">Harvest Light.</a> - <!-- That would go to a file with that name contained in the same folder as the current page -->
<a href="../light.html">Light</a> - <!-- This would go to a file one folder level above the current page -->
<a href="foldername/condemnation.html">Now no condemnation.</a> - <!-- that would go to a file one folder level below the current page -->
<a href="http://www.yoursite.com/harvest.html">People are the Harvest.</a> - <!-- this is an absolute path and will go to the file that has that exact web address -->
<a href="#section5">Personal Testimony.</a> -
<a href="#section6">Accept Jesus.</a> -
<a href="#section7">Buy the booklet.</a> -
<a href="#section8">Write the Vision.</a> -
<a href="#section9">Contents of booklet.</a>-
<a href="#top">This page</a></p>
I hope this helps. For every folder level you want to go up you need a "../" which will take you up one level each time it is used so a file located two levels above would be "../../". For files that are in folders below you would use "foldername/" and two levels would be "foldername/foldername/"
effpeetee
08-08-2008, 09:19 PM
Many thanks to you all. I have found the answer by looking very carefully to your replies. I told you I was tired.
I had forgotten the suffix .html.
Black mark Taylor!
Deduct twenty Brownie points.
Thanks to all.
Frank
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.