title: How does Node.js render views?
body: <p>In a basic Node.js application with a single <code>app.js</code> file and one <code>index.html</code> document where in <code>app.js</code> the following is specified, then firing up a server and visiting <code>localhost:8080</code> works just fine:</p>
  
  <pre><code>server = http.createServer( function(req, res) {
      fs.readFile('index.html', function(err, page) {
          res.writeHead(200, {'Content-Type': 'text/html'});
          res.write(page);
          res.end();
      });
  
      fs.readFile('new.html', function(err, page) {
          res.writeHead(200, {'Content-Type': 'text/html'});
          res.write(page);
          res.end();
      });
  });
  
  server.listen(8080);
  </code></pre>
  
  <p>However, when duplicating <code>index.html</code> to another file like <code>new.html</code> and editing certain content, then adding an  link into <code>index.html</code> linking to the new page, clicking on the link will render the same content as in <code>index.html</code>. In fact, linking to any non-existent html page will append the subsequent page to the URL but keep showing <code>index.html</code>'s contents.</p>
  
  <p>Following a suggestion of rewriting the fs.readFile line to be:</p>
  
  <pre><code>fs.readFile(req.url, function(err, page) { ...
  </code></pre>
  
  <p>Then going to <code>localhost:8080</code> loads <code>new.html</code>'s contents for some reason I don't understand. How should one render out these views?</p>