To render template files, set the following application setting properties, set in app.js in the default app created by the generator:
views , the directory where the template files are located. Eg: app.set('views', './views') . This defaults to the views directory in the application root directory.
view engine , the template engine to use. For example, to use the Pug template engine: app.set('view engine', 'pug') .
The relevant part for your case is:
This defaults to the views directory in the application root directory.
Since app.set('views', './views') wasn’t explicitly set in the server.js file, Express just uses the views directory in the root of your project.
To render a view, you don’t need to specify the views directory as Express is using it as the default in your case, so you only need to specify the file path relative to the views directory, which is pug/index.pug, but since the view engine property is set, you don’t need to specify the file extension, so pug/index would be adequate.
Actually, you could remove app.set("views", "./views") if you wanted to, and it would still work. As I mentioned, Express will use the views folder in your project root by default.