Cannot link the style.css file on Route()

Hey guys, i have a problem on my project. So if i define a route like this :slight_smile:

routers/shop.js

const express = require("express");
const router = express.Router()

router.get("/shop", (req, res) =>{
  // code goes here 
});

module.exports = router;

app.js

let shopRoute = require("./routers/shop.js");

app.use("/list", shopRoute);

The router works fine but stil.css not loading. Any idea?

Have you defined your static asset folder?

yes i did it on shop.ejs file. I did it too :

app.use(express.static("public"));

You should include that on your main “controller” file (index.js, server.js, etc)

i defined my public folder in my server.js file

Can I see where you link your style.css file?

The EJS file?

<!DOCTYPE html>
<html>
<head>
<h1>Shop List</h1>
</head>
<body>
<div align = "center" class = "shop-container">
<ul>
<li><%= item1 %></li>
</ul>
</div>
</body>
<link rel = "stylesheet" href = "stil.css">
</html>

Can you share a link to your code/project name? I also think Riverside wanted to see the res.render.. line.

nevermind guys i fixed it thanks a lot again

3 Likes