Recently, I encountered an issue where the CSS styles were not being applied to my HBS code despite several attempts.
The structure of my service is as follows:
- Service
- Controllers
- Models
- public
- css
- styles.css
- css
- Routers
- Views
- index.hbs
- app.js
- package.json
- Procfile
- node_modules
- package-lock.json
Now, I want to link my index.hbs file to the "styles.css" stylesheet in the public css folder. To do this, I included a reference in index.hbs as follows:
link rel="stylesheet" href="../public/css/styles.css">
I also added app.use(express.static(path.join(__dirname, '/public'))); in my app.js
Despite clicking on the reference in the HBS file within VSC which takes me to the correct CSS file, the styles still do not work when running the app. Could it be an issue with the app routing? I have exhausted all possible solutions and would appreciate any feedback.
- Fred