Hello, my CSS and JS are not rendering when I run my Netlify website. The HTML links all work perfectly but the CS and JS don’t work. I’ve looked at other posts but I haven’t been able to fix my problem. The CSS files render when I run it on vscode. Any help would be appreciated. Thanks in advance.
From what I can see look at the repository and the live site, you have deployed the pages directory. The issue then is the styles and the js directories are in the root of the repository, thus do not get deployed.
You either need to move everything in the pages directory into the repository root and deploy from the root (i.e. leave the publish directory empty) or move everything else in the repository into the pages directory.
oh, I see. I set it that way because my index.html file was inside of the pages folder. Is there a way to still access the index.html file in a folder and also have the CSS files render from another folder?
which technically, if the root of the repository was deployed, would work, however doesn’t work in this instance. So if you move this file up one level to the repository root, the above line would need modifying to
<link rel="stylesheet" href="styles/about.css">
or
<link rel="stylesheet" href="/styles/about.css">
The same goes for any <img>, and <script> tag that reference files within the project.
I’m facing this issue too right now and I’m still not quite sure how to fix it after reading this thread. Could you take a look at my file and advice on it please?
My github repo: GitHub - Sopheaktra-Phol/food-blog