Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

467
Vistas
CSS not linking to Ejs file

I believe this is the correct way to link the css to the ejs file, however it's still not working. You can see how all my folders are arranged in the pictures provided.pic1 pic2 enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

In your server.js file, use this line instead of the one you have :

app.use(express.static(path.join(__dirname, "/public")));

The line above tells express where to find public assets. With this, evrytime you write / in a ejs file, you are already in the public folder.

You will for example link your css file like so (I assume your css styles are inside public/css/styles.css):

<link href="/css/styles.css" rel="stylesheet">
about 4 years ago · Juan Pablo Isaza Denunciar

0

your problem is not with the link tag in your Ejs file. the problem is with defining the path for your file inside the server.js file

the solution is to use static method inside the express 'use' middleware as the following:

app.use(express.static(__dirname + '/public'));

this means that you are telling express where to find and serve static files.

for linking the css file, all you have to do inside your Ejs file is to add a link tag as follows:

<link href="/css/styles.css" rel="stylesheet" type="text/css">
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda