Building an e-Commerce website with Node – Part 16 – Sign up page creation

We have the signup route but we don’t have the signup page. We are going to create it and store it in a new folder named “accounts”.

In the “views” folder create a new folder called “accounts” and inside the “accounts” folder create a file named signup.ejs. Now, let’s start adding code to our signup.ejs page. It is just HTML code with bootstrap classes.

<% layout('layout') -%>

<div class="row">
  <div class="col-lg-6 col-md-offset-3">

    <form method="post">

        <input type="text" class="form-control" name="name">
        <input type="email" class="form-control" name="email">
        <input type="password" class="form-control" name="password">


At the top you can see <% layout('layout') -%>. We don’t have this layout yet. Go to boilerplate.ejs, copy the whole code and paste it in a newly created file named layout.ejs (under the views folder). At this point, boilerplate.ejs and layout.ejs are identical but we are going to customize layout.ejs to look like a signup page not like a product page. So, let’s do it!

Move the navbar div to the partials/navbar.ejs. So, our navbar.ejs looks like below:

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          <a class="navbar-brand" href="#">Project name</a>
        <div id="navbar" class="navbar-collapse collapse">
          <form class="navbar-form navbar-right">
            <div class="form-group">
              <input type="text" placeholder="Email" class="form-control">
            <div class="form-group">
              <input type="password" placeholder="Password" class="form-control">
            <button type="submit" class="btn btn-success">Sign in</button>
        </div><!--/.navbar-collapse -->

The footer div would be moved to partials/footer.ejs. The footer.ejs looks like below:

        <p>&copy; 2016 Company, Inc.</p>

Let’s continue deleting everything we don’t want in out layout.ejs file. At the end, everything is left is the code below:

<!DOCTYPE html>
<html lang="en">
    <title>Jumbotron Template for Bootstrap</title>
    <!-- <link rel="stylesheet" href="/css/bootstrap.min.css"> -->
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="/css/custom.css">

    <% include ./partials/navbar %>
      <!-- Example row of columns -->
      <%- body -%>
      <!-- /container -->
      <% include ./partials/footer %>

Now, we have to add in the user.ejs the route to the signup page.

router.get('/signup', function(req, res, next) {

Now, if you check the page in the browser it shows up but it looks ugly. In the next post we are going to customize it a little bit to make it look better.

Leave a Reply