I have few routes in my website and I use the same layout with linked styles for all of my pages.
For example in route /
or /abc
or /other
my layout and styles works good. However, if I load route /other/abc
my layout still works but my styles don't load.
Here's some code:
My layout
:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Express MVC Example</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<ul class="menu">
<li><a href="/">home</a></li>
...
<li><a href="/other/abc">other/abc</a></li>
</ul>
{{{ body }}}
</body>
</html>
This is my other
route controllers
:
import express from 'express'
export default (app) => {
const api = express.Router();
api.get('/', (req, res) => {
console.log('client connected');
res.render('other/main');
});
api.get('/abc', (req, res) => {
res.render('other/abc');
});
return api
}
I use handlebars
for views
.