Im beginner and im practice to study nodejs (empress) every thing it’s going smoothly untill i css my file
viewEngine file
const path = require('path');
const express = require('express');
const configViewEngine = (app)=>{
app.set('views', path.join('./src','views' ));
app.set('view engine', 'ejs')
app.use(express.static(path.join('./src','public')))
}
module.exports=configViewEngine;
homePage.ejs file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="/src/public/css/style.css">
</head>
<body>
<div class="haha">
<h1>ahahahhahahaha</h1>
</div>
</body>
</html>
css file
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.haha{
color: red;
}
location of all my file
IM TRYING TO ADD SOME CODE LIKE THIS IN VIEWENGINE FILE BUT IS NOT WORK
app.use(‘/public’, express.static(‘public’));
Sorry i forgot to mention my problem 🙁 My ejs file cant link with my css file 🙁
One more thing is i can style inside ejs file but cant style through css file
Just try to with <link rel=”stylesheet” href=”/css/style.css”>