I am a newbie. I have just read Build Your Own Website The Right
Way by Ian Lloyd and I am having a problem with broken links on my website.
I created a website which works perfectly on my laptop but after uploading
the website using FileZilla FTP to my ISPs server I have found that none of
my links work. I have validated both my CSS and my XHTML using the W3C
validator tools and found no errors. Please could you suggest what has gone wrong?
Check your links code, i`m sure your links are absolute related to your computer, like this: <a href="file:///C:/pictures/xyz.jpg"> so they are searching for drive C:\, on your pc. Your links should be relative, like <a href="pictures/xyz.jpg"> , so they will search on your server. Could also be absolute or root-relative , but to your website (<a href="http://www.yoursite.com/pictures/xyz.jpg">)
Hi jonathanbarton. Welcome to the forums.
If webcosmo's answer doesn't help, please post a link to your site, or at least an example of the code used in your links.
Try right click on your online images and look for image source or image details and the online path to the image should be displayed.
...no wait, you meant web links...:D
Hi jonathanbarton. Welcome to the SitePoint
it is likely that you built your site using absolute links ( possibly using Dreamweaver?). So when you the files to yours server your links are wrong( the HREF string didn't change, but the server wouldn't have an idea of where "http://mycomputer/c-drive/webpage/index.html"
Go back an check your links if the HREF begins with "http:" or "file:" you have used absolute links!
Unless you are building your site directly on a server ( and NEVER expect to move it to another location) it's almost always better to use relative links.
href="index.htm" ( a file in the TOP directory of your site, linking to INDEX.HTM file which is ALSO in the top directory)
href="folderName/file.htm" ( a file in the TOP directory of your site, linking to FILE.HTM , file resides in folderName, folderName in the top directory)
href="../other.htm" ( a file , linking to other.HTM...which is in a parent directory )
hope that helps
Hello Ralph.M. As far as I can make out I am using relative links at the moment. I copied my code below:
<li><a href="about.html">About Us</a></li>
<li><a href="events.html">Club Events</a></li>
<li><a href="contact.html">Contact Us</a></li>
<li><a href="gallery.html">Image Gallery</a></li>
The url of the website is: http://homepage.ntlworld.com/jonathanbarton1/
If you visit the website you will see that I cannot get the links to work. Do you have any other suggestions?
OK, so the question we need to ask now is—Where are those pages currently located on your server? They should be inside the /jonathanbarton1/ folder, but they aren't there. (Are you sure you have uploaded them at all? Check in your FTP program to make sure they actually got uploaded.)
(Note also that in your online version of the menu, you have a gap before the gallery URL:
<a href=" gallery.html">
Remove that gap before the g or you will have a problem with that link.)
I just did some fishing, and discovered that the reason your links are not working is that your file names start with a capital letter (e.g. About.html) while your links point to files without a capital at the start (e.g. about.html). As a rule, never use capital letters in HTML or CSS code. It's just one more source of trouble you can do without.
Thanks for that. It is now working.
No worries, glad we could help. Do come back if you have more questions.
This topic is now closed. New replies are no longer allowed.