K. van den Berg K. van den Berg - 1 month ago 9
HTML Question

HREF to another rendered pug file

I'm making a website in Pug with Nodejs and Express.
I made a file called

index.pug
. In this file I included all my pug files.

index.pug:

extends ../views/layout

block content
include home/page-content/Intro/Intro
include home/page-content/About/About
include home/page-content/Specialism/Specialism
include home/page-content/Contact/Contact
include home/page-content/Footer/Footer


Intro.pug href:

a(style="color: #f0ad4e", href='indexHelp')
span(lang='nl') Help
span(lang='en') Help


This
HREF
need to redirect to a file named
indexHelp.pug
. But I render all my pug files automatically to
html
files. So it can't find my indexHelp.
IndexHelp.pug
is like
index.pug
. When I click on that href it needs to show all the pages who are defined in
indexHelp.pug
.

Can someone please help me with my href?

Edit

Routes\index.js

var express = require('express');
var router = express.Router();
var index = require('../controllers/index');

/* Index */
// router.get('/', index.index);

router.get('/indexHelp', function(req, res) { res.render('indexHelp'); });

module.exports = router;

Answer

One option is to have the href point to a route on your website, from which you can render the indexHelp. So:

a(style="color: #f0ad4e", href='//yourDomain/indexHelp')

Then you have a route set to accept this:

router.get("/indexHelp", (req, res) => {
    res.render("indexHelp");
};