Search code examples
cssexpresspug

Link to CSS in Pug/Express is not working


My paths are as such:

src
  index.ts
public
  css
    (css files)
views
  sections
    master.pug

In my index.ts I have this piece of code: app.use(express.static(path.join(__dirname, 'public')));

So in my master.pug I wrote this, and thought it would work: link(rel='stylesheet', href='/css/style.css', type='text/css')

Does anyone know how to fix this issue? Something I'm overlooking? Any help would be great! I'll post my fix if I find one before something pops up here. :)


Solution

  • Try using this, app.use(express.static('public')); Here public is folder name which contain all static files and your public folder should be on same hierarchy level.