I am very new to html/css/js, and teaching myself by building a personal website. However, when I attempt to run the website using http-server, the server reports 404 errors for the stylesheets when the page is loaded. The resources in question are found as expected when I open the html file directly w/o using http-server. I suspect that my problem is simply that I do not understand how to format pathnames correctly, but am not sure.
The file structure:
My code from index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Home</title>
<link rel="stylesheet" type="text/css" href = "css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
The errors generated on opening the page:
[2022-08-18T21:21:16.660Z] "GET /css/style.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0"
[2022-08-18T21:21:16.662Z] "GET /js/index.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0"
[2022-08-18T21:21:16.663Z] "GET /css/bootstrap.css" Error (404): "Not found"
[2022-08-18T21:21:16.667Z] "GET /css/style.css" Error (404): "Not found"
[2022-08-18T21:21:16.668Z] "GET /assets/images/ag.jpg" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0"
[2022-08-18T21:21:16.669Z] "GET /js/index.js" Error (404): "Not found"
[2022-08-18T21:21:16.670Z] "GET /assets/images/ag.jpg" Error (404): "Not found"
[2022-08-18T21:21:16.689Z] "GET /js/index.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0"
[2022-08-18T21:21:16.690Z] "GET /js/index.js" Error (404): "Not found"
What I've tried:
Specifying the path using ../css/, ./css/, /css/, ~/css
Moving the css file into the same directory as index.html and changing the href to ".css"
Moving the index.html to the project root.
Changing the base href to ., ./, ../
Where I've looked for answers:
https://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/
GET 404 error for style.css not found
css and js files not found(server responded with a status of 404) while browsing application on iis7
Now I'm at the "Go take a walk and clear your head" stage of troubleshooting, but thought I'd post here before I do so. Any assistance is greatly appreciated!