0

This is my structure

enter image description here

I'm trying to load the main.css file from the header.ejs file, can't find it.

This code is in my header file:

<!DOCTYPE html> <html>
    <head>
        <title>Hello and wellcome to my album</title>
        <link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
        <link type="text/css" rel="stylesheet" href="../../public/stylesheets/main.css">

    </head>
    <body>
Community
  • 1
  • 1
asaf
  • 119
  • 2
  • 10

6 Answers6

3

Try to go 2 directories back, not 1.

Like this:

<link type="text/css" rel="stylesheet" href="../../public/stylesheets/main.css">
Paul Isaris
  • 414
  • 4
  • 13
1

Link should be like below cause you have 2 sub folder back then you will get public folder and stylesheets

  <link type="text/css" rel="stylesheet" href="../../public/stylesheets/main.css">
Destroyer.0211
  • 113
  • 1
  • 3
  • 13
1

Try

<link type="text/css" rel="stylesheet" href="../../public/stylesheets/main.css">

.. selects the parent directory from the current.

(..) 2 times because first, you need to go 2 directories back and then go to public and then stylesheet and then main.css

theboringdeveloper
  • 1,429
  • 13
  • 17
1

in app.js i added:

app.use(express.static("public"));

in the header.ejs i changed:

<link type="text/css" rel="stylesheet" href="stylesheets/main.css">

i am using NodeJS

asaf
  • 119
  • 2
  • 10
0

The problem is that your stylesheet path is set wrong.

<!DOCTYPE html> <html>
<head>
    <title>Hello and wellcome to my album</title>
    <link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="../../public/stylesheets/main.css">
</head>
<body>

You are pointing just a folder up from partials to views. You need anothe folder up to your site root dir just like I pointed. Generally you could just use /public/stylesheets/main.css which is directly pointing to project root folder

dstrants
  • 7,423
  • 2
  • 19
  • 27
0

This is a nodejs app, path should be like following.

<link rel="stylesheet" type="text/css" href="/stylesheets/main.css" />

If your path static:

<link rel="stylesheet" type="text/css" href="stylesheets/main.css" />
sametcodes
  • 583
  • 5
  • 8