2

I need to add css file named feed.js with a pug file named feed.pug. i am trying this in feed.pug but it is not working

link(rel='stylesheet', type='text/css', href='feed.css')

this is my css code;

body{
    background-color: red;
}

I have also tried one or two solutions from stackoverflow but this is not working. pugjs(jade) template engine loading css file

Need help :)

palo
  • 159
  • 2
  • 12

1 Answers1

4

This might simply take a little messing around with finding the right location to use. I would imagine you need

link(rel='stylesheet', type='text/css', href='/feed.css')

Note the forward slash in front of feed.css. On the server side, you need something like the below if you are using express.

var express = require('express');
app.use(express.static('css'));
freqnseverity
  • 146
  • 1
  • 7
  • In your base folder, do you have a folder called 'css'. Is your css file in that folder? – freqnseverity Jun 30 '20 at 12:29
  • no i don't have any specific folder for css. I have one folder in which all css , js and html files are placed and only one ```views``` folder within that folder for pug. – palo Jun 30 '20 at 12:31
  • 1
    Ah, you should try href='../feed.css'. These things can take a bit of tinkering. Also, on your server side, you need to have app.use(express.static('your_folder_for_static_files')) – freqnseverity Jun 30 '20 at 12:34