How can I set different <title> values ​​for each template in ejs?

I am using Sails.js and it comes with ejs templates. There is a default view called layout.ejs, which always includes body parts from other templates. The title element is defined in layout.ejs and is therefore always the same. Due to SEO I would like to change the title depending on the included view. Is there a way to find out which view is actually being called from Sails in the .ejs file?

+3


source to share


1 answer


Update <title>

your tag layout.ejs

to

<title><%= title %></title>

and send the value title

from your controller along with other data like



res.view('viewname', { title: 'YourTitle', data: data });

Hope this helps!

+4


source







All Articles