Reputation: 79
I'm absolutely new to pug and javascript itself. I have a little problem, can anyone please tell me what's wrong? My goal is to make several .pug files with text, so that ill be able to press on link and go to another text .pug file.I created an express app with node.js. I have a simple index.pug.
extends layout
block content
h1= title
p Welcome to #{title}
a(href="about.pug") this is the link text
So i just want to make a link from my main file index.pug to about.pug file, which is in the same folder and has absolutely same code inside. But each time i click the link it just says 404 not found (if i use website link such as www.youtube.com, link does it's task). I don't really understand...file exists, nevertheless it says 404 not found... Do i need to do some operations with routes? I haven't done any changes there.
Upvotes: 2
Views: 5257
Reputation: 707328
So, change the href to '/about'
:
(href="/about") this is the link text
And create a route in your Express server for it:
router.get('/about', (req, res) => {
res.render('about', {title: "something"});
});
Upvotes: 2