I'm trying to use stylesheets and javascript files on my node.js project which uses express and ejs.
my structure:
public/
-- css/
-- js/
-- images/
and my chat.ejs file:
<!DOCTYPE html>
<html lang="en">
<head>
<% include ../partials/head %>
</head>
<body>
.. content ..
<% include ../partials/footer %>
</body>
</html>
and in my partials/head.ejs there is code
<link href="public/css/custom.css" rel="stylesheet">
and it should load style file but it doesn't. Btw my main chat.js:
var express = require('express');
var app = express();
// set the view engine to ejs
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/public'));
// index page
app.get('/', function(req, res) {
res.render('pages/chat');
});
app.listen(3000, function(){
console.log('listening on *:3000');
});
so how to use it properly?