Problems loading pages and images using 'href' and 'src' - html

I'm having trouble setting up the proper paths for my website, using 'href', I keep getting the 404 error when I'm on the github pages for it, but while developing on live server it works perfectly, making it hard to get what am I doing wrong. for example, on the root of the site I have the index.html and a couple other pages, those work with no problems, but then I created a folder to hold the other pages (called 'sub-pages') but everything I put on there does not get redirected at all, giving me the 404 error. for example, If i do href="index.html" it works, but if I do href="pages/sub-pages/page" I get 404'd while on the gitpages but on the live server it works no problem

The way a path is interpreted is different according to the system.
Try href="./[subfolder]/page.[extension]"

Related

Anchor tag working locally, but not when deployed

Weird problem I'm running into... This anchor tag
<a target='_blank' href='jresume.pdf'>Resume</a>
is working fine locally. Opens a new page and loads my pdf file.
But for some reason when I deploy my site to surge.sh the link no longer works and gives me this error "No webpage was found for the web address: http://sitename.surge.sh/jresume.pdf"
if anyone could help that'd be great. Thanks
The first step I would take is to make sure the file is in the right place on your web server (have you actually uploaded the file to your web server?). I guess that'd be in the same folder as your index.html or the same folder as whatever html file is linking to it.
If that's not the problem I'd try changing href='jresume.pdf' to href='./jresume.pdf' and seeing if it makes a difference.

failed to load resource hexo.js

I'm using HexoJS to create a blog. I was able to generate the static files using hexo generate. Even though there are css files and JS files generated, they are not properly linked to the index.html.
So, I have to open each html page and correct each page links given in href and src attributes one by one. I believe that this is not very practical. Can anyone help ?
The localhost is used for preview the website. When we publish our blog, it should be on a server, then the path will be interpreted correctly, we don't need to change any thing. What we saw on http://localhost:4000 will be same when you published your website.
So, we don't have to worry about the broken paths in the public folder.

Change index.html into start.html

Please I hope somebody can help me because i've been dealing with this problem already for about 2 weeks and I just can't figure out how to fix it.
I have added a new part to my website since I'm offering a totally new service. I put the new part under index2.html.
I have a new start/default page called start.html, on here they can choose to click on the service they are coming for, so will be either going to the old website part which is under index.html or they will go to the new part which is under index2.html.
To have people go directly to start.html I have put DirectoryIndex start.html in my htaccess file and this works fine. But when they choose which website part they want to go to and click on it they don't get the website index.html or index2.html but they get a message in the screen that their connection is not private and you will see a red https in front of the url link. I don't want it to be https, it just needs to be http.
Individually all the links work fine. So I don't understand why the message appears and what can I do about it?
I also did a link check on W3C, it said:
error Line: 87 www.example.com/index2.html
Status: 500 Can't connect to www.example.com:443
This is a server side problem. Check the URI.
error Line: 78 https://www.example.com/index.html
Status: 500 Can't connect to www.example.com:443
This is a server side problem. Check the URI.
Using index.html as the default file for /folder/,
ie. pointing the browser to /folder/ takes you to /folder/index.html
is such a widespread convention, you are almost definitely better off not messing with it.
My suggestion would be:
Rename /index.html to /old-part/index.html
Rename /index2.html to /new-part/index.html
Rename /start.html to /index.html
I concur with Rounin. A browser/website is designed to look for a file called index.html, index.php, index.xhtml, and so forth for the main page of the site depending on the type of website it is when it comes to your domain.
You need to do what Rounin suggested for your files to maintain a proper website without any headaches.

Images broken on server

I am making a webpage and I am including these images, when I run the page off of notepadd++ everything works fine but after I upload it to the server and I try to run it, the images are broken and I am getting this message on the console : Failed to load resource: the server responded with a status of 404 (Not Found)
<a href="games/rockpaper/main.html"><img class = "rock" src="images/rockpaper.JPG" alt="Thumbnail of the rock-paper-scissors game"><a>
<a href="games/typing/TypingTest.html"><img class = "typing" src="images/typing.JPG" alt="Thumbnaul of the typing test game"><a>
Although I'm not entirely sure what you're saying in your comment. I suspect two things:
Make sure that your image src is relative to your actual directory layout. For example if the file that contains that code is in "home", make sure that your images are in "home/images/xx.JPG"
If you're developing on a windows computer and hosting on a unix server, make sure that the case of the directories and files are identical. Windows is not case sensitive where as unix is. If you uploaded typing.jpg and are looking for typing.JPG, it will not find it.
The JPG as the end of the src link needs to be lower case. for example
src="images/rockpaper.JPG"
should be
src="images/rockpaper.jpg"
You need to close them with </a>, not <a>.

First website, only index.html page loads

I have made my first website and in the preview in Safari and Chrome from Dreamweaver it works fine. But after uploading my files with Filezilla to 000webhost and typing in the URL, only the index page loads, links to other pages on the site don't work, images are broken and the css isn't applied.
I'm think it is because I haven't named the files correctly in the code, but I have no idea what to call them in order to get it right.
The file you upload to is public_html. So I've tried http://www.webaddress/public_html/Pages/entertainment.html but it didn't change anything.
Thanks for any help!
Without code examples it's very difficult to answer this, but it's probably just that your URL format is incorrect.
For example, if you've got example.com/example/example.html and that page contains a CSS file with a location of /css/style.css, the web browser will look for example.com/css/style.css because the slash at the beginning of the URL tells it to go to the root.
In this case, your CSS file is probably actually in example.com/example/css/style.css. Remove the beginning slash so the location is css/style.css and the web browser will look for the file using the current page's location as it's starting point.