How do you render a page, but with the anchor tag as well in express.js routes?
So: website.com/route#id-of-html-element
How do you render a page, but with the anchor tag as well in express.js routes?
So: website.com/route#id-of-html-element
It seems like if you code your hyperlink in the usual way and add the anchor <a href="/route#anchor1">link</a>, then add the anchor id/name on the desired destination page <a id="anchor1" name="anchor1"></a>, express will simply carry the #anchor1 over to the routed page and the client will then jump to where the anchor is. Nothing special in the routes code is required. This seems to work fine using res.render in my test.
router.get('/route', (req, res, next) => {
res.render('route')
});