app.get doesn't work properly express.js

app.get('/:id', function (req, res){

   UserModel.find({ user: req.params.id}, function (err, user){

         if (err) throw err;

         console.log(user + '\n\n');

         res.render('profile.ejs', {

                username: user[0].user,
                avatar: user[0].avatar,
                followers: user[0].followers.length,
                following: user[0].following.length

         })

   });

});

I don't know why, when, for example, I write <a href="/<%= username %>">...</a>, I go to /randomuser/ instead /randomuser. Is this a problem if I try to render a png in /:id, from a static directory? Because I think yes! The png doesn't render, but in other page that doesn't end in / it works.

Not positive I understand the question but you should be able to get it to work by changing

app.get('/:id', function (req, res){

to

app.get('/:id/', function (req, res){

the png should render if it dosent work let me know

You Will Get Redirected to /randomuser/ or /randomuser depending on what the route is in app.get. It doesn't matter as far as I know. let me know if you have any other questions