title: Links not working in multipage site with node.js and ejs
body: <p>I am having trouble with my multi-page website in node.js/ejs.  I presume it’s a route problem but I believe my routes are set up correctly.  My index page renders fine but when I try to follow a link on the page, I get a “Cannot GET /” error.</p>
  
  <p>My relevant front-end code:</p>
  
  <pre><code>&lt;nav id="main_nav"&gt;
  &lt;a class="button_horizontal" href="index.ejs"&gt;HOME&lt;/a&gt;      
  &lt;a class="button_horizontal" href="about.ejs"&gt;ABOUT&lt;/a&gt;
  &lt;a class="button_horizontal" href="portfolio.ejs"&gt;PORTFOLIO&lt;/a&gt;
  &lt;a class="button_horizontal" href="events.ejs"&gt;EVENTS&lt;/a&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>My relevant node.js code:</p>
  
  <pre><code>app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(favicon(path.join(__dirname, 'public/images', 'favicon.ico')));
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  app.set('view options', __dirname + '/views/pages/layout');
  app.set('images', __dirname + '/public/images');
  app.use('/', routes);
  app.use('/users', users);
  
  // Create server
  var server = http.createServer(app).listen(4000,function(){
      console.log("We have started our server on port 4000");
  });
  
  // Load website
  app.get('/', function(req, res) {
      res.render('index', { });
  });
  </code></pre>
  
  <p>And my file structure:</p>
  
  <pre><code>views/
      index.ejs
      about.ejs
      portfolio.ejs
      events.ejs
  public/
      css/
      images/
      js/
  routes/
      index.js
      users.js
  </code></pre>
  
  <p>I’d be very grateful if anyone can spot what I’m missing as I can’t seem to find any tutorials that use more than one page for the website!</p>