How can I include css files using node, express, and ejs?
css, ejs, express, node.js
Solution
Use this in your server.js file
app.use(express.static(__dirname + '/public'));
and add css like
<link rel="stylesheet" type="text/css" href="css/style.css" />
dont need / before css like
<link rel="stylesheet" type="text/css" href="/css/style.css" />
Problem
I'm trying to follow the instructions to https://stackoverflow.com/a/18633827/2063561, but I still can't get my styles.css to load. From app.js ``` app.use(express.static(path.join(__dirname, 'public'))); ``` In my .ejs, I have tried both of these lines ``` <link rel="stylesheet" type="text/css" href="/css/style.css" /> <link rel="stylesheet" type="text/css" href="/public/css/style.css" /> ``` Neither loads the css. I've gone into the developer's console noticed the type is set to 'text/html' instead of 'text/css'. My path looks like ``` . ./app.js ./public /css /style.css ```