javascript – Can't link my css file to header partial properly-ThrowExceptions

Exception or error:

I’m trying to add my CSS file to my header partial

This is my link:

<link rel="stylesheet" href="stylesheets/app.css">

my directory:

project
   models
   node_modules
   public
      stylesheets
         app.css
   views
      partials
         header.js

Where is my mistake?

How to solve:

A CSS file cannot be included in a JS file. You must include the CSS file in a HTML file.

###

1) If you are using Express, then include this in your main javascript file (app.js/index.js/where ever your routes are):

//Use public dir:
app.use(express.static(__dirname + "/public"));

2) Change your header partial from header.js to header.ejs. Make sure your link

<link rel="stylesheet" href="stylesheets/app.css">

is included here.

3) At the top of the desired “views” file, be sure to include:

<%- include("partials/header") %>

Leave a Reply

Your email address will not be published. Required fields are marked *