Reputation: 223
I am developing a nodejs application using the Jade template engine.
Inside my main("/") layout I have the following code that loads external CSS in my public path.
link(rel='stylesheet', href='/stylesheets/styles.css')
...
there are multiple lines of external javascript and css files to be loaded.
However, When I have to load it from my /users/profile jade template the link is broken.
It says
GET http://localhost:3000/users/javascripts/underscore.js 404 (Not Found)
Is there a way to have a set of links that works in all of my Jade template so I don't have to manually redefine them everytime?
Thanks in advance, Dennis
Upvotes: 3
Views: 2150
Reputation: 26940
If you are using express
do it like this:
app.use(express.static(__dirname + '/public'));
link(rel='stylesheet', href='/stylesheets/styles.css')
this will make following http request: GET http://localhost:3000/stylesheets/styles.css
and express will look for the file in directory: ~/public/stylesheets/styles.css
Upvotes: 5