Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
Unable to load "style.css" in pug file using nodejs

I am new in nodejs and i am using "expressjs" framework,And i am trying to show simple static page using "pug" extension but "css" file is not loading/working Here is my file strcture

demo(Main Project/root)
    index(Main file)
    views
        public
            views
                dashboard
                    style.css

And here is index.js code

var express = require('express')
var app = express()
//app.use("/styles", express.static(__dirname + '/styles'));
var path = require('path');

app.set('views', path.join(__dirname, './views'));
app.set('view engine', 'pug');
app.use(express.static(path.join(__dirname, 'public')));


app.get('/first_template', function(req, res){
   res.render('index');
});

app.listen(3000)

Here is my index.pug code

html
      head
        title Dashboard
        link(rel='stylesheet', href='/views/dashboard/style.css')
      body
      p Hi!

How can i add "style.css" to index.pug ? Where i am wrong ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!