웹프로그래밍/node.js & Typescript
[node.js] adding .css file to ejs
jihun202
2016. 5. 16. 09:38
반응형
Your problem is not actually specific to ejs.
2 things to note here
-
style.css is an external css file. So you dont need style tags inside that file. It should only contain the css.
-
In your express app, you have to mention the public directory from which you are serving the static files. Like css/js/image
it can be done by
app.use(express.static(__dirname + '/public'));
assuming you put the css files in public folder from in your app root. now you have to refer to the css files in your tamplate files, like
<link href="/css/style.css" rel="stylesheet" type="text/css">
Here i assume you have put the css file in css folder inside your public folder.
So folder structure would be
.
./app.js
./public
/css
/style.css
반응형