title: Active menu item in node.js and express
body: <p>I am using <code>node.js</code>, <code>express</code> and <code>express-handlebars</code>. I have a menu in the top of my layout.</p>
  
  <p>In my <code>server.js</code>, I set all the pages with</p>
  
  <pre><code>app.locals.pages = [
    { title: 'Home', link: '/' },
    { title: 'About', link: '/about' },
    { title: 'Contact', link: '/contact' },
  ];
  </code></pre>
  
  <p>and in the layout file, I print the pages with</p>
  
  <pre><code>{{#each pages}}
    &lt;li class="nav-item"&gt;
      &lt;a class="nav-link" href="{{link}}"&gt;{{title}}&lt;/a&gt;
    &lt;/li&gt;
  {{/each}}
  </code></pre>
  
  <p>but I want to add a class to the menu item which is currently being active.</p>
  
  <p>How can I save which of the 3 menu items is active?</p>