EJS template question

I placed my new websites markup into an ejs file then put <%- body %> into another file then rendered it to '/ ’ it worked and my page is now hosted on localhost3000 however I have no styling.
What do I do with the css styling for that page? Does the css file also go into the views folder?

I hope I made my question clear if not here’s the shorter version.

How do I make css styling render along with .ejs markup?

in my server file I’m using

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

and in the markup I have

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

I also created a public directory that’s holding my indexStyle.css file

Check your browser console. Is indexStyle.css it trying to load but 404ing? Does it show up in the Sources pane? Does the link rel="stylesheet" show up correctly in the HTML?

localhost/:1 Refused to apply style from ‘http://localhost:5000/indexStyle.css’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.

then a bunch of 404 errors for the missing pictures as well

If you open http://localhost:5000/indexStyle.css directly in your browser, is it your CSS, or some HTML error page, or something else? You can find some troubleshooting tips in this StackOverflow thread:

nope If I type that url i get the “Cannot Get /indexStyle.css”

This has been driving me crazy haha, I just wanna know at this point.

Did you check the SO thread I linked to? This answer deals specifically with the Node/Express case.

1 Like

I’m reading through it right now thank you

That was it! just one single ‘/’ I just sifted through so much code for a single slash :rofl: Thank you I’ll now know this for life haha

1 Like

A bunch of 404 errors for the missing pictures as well