Try this .. instead of app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(__dirname, 'public')); On Saturday, July 2, 2016 at 9:38:57 PM UTC-4, [email protected] wrote: > > Is here someone who can help me out. I have a problem with > node.js/express/express-ejs-layouts. I have included express-ejs-layouts in > my code and set the layout. It all works, only a little bit too good. > Because it adds also the layout by the .css files that included in the head > of the layout file. How can I change that? > > app.js > var express = require('express'); > var path = require('path'); > var favicon = require('serve-favicon'); > var logger = require('morgan'); > var cookieParser = require('cookie-parser'); > var bodyParser = require('body-parser'); > var expressValidator = require('express-validator'); > var flash = require('connect-flash'); > var session = require('express-session'); > var passport = require('passport'); > var LocalStrategy = require('passport-local').Strategy; > var mongo = require('mongodb'); > var mongoose = require('mongoose'); > var expressLayouts = require('express-ejs-layouts'); > > > var routes = require('./routes/index'); > var users = require('./routes/users'); > > var app = express(); > app.use(expressLayouts); > > // view engine setup > app.set('views', path.join(__dirname, 'views')); > app.set('layout', 'layouts/layout'); > app.set('view engine', 'ejs'); > > // uncomment after placing your favicon in /public > //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); > app.use(logger('dev')); > app.use(bodyParser.json()); > app.use(bodyParser.urlencoded({ extended: false })); > app.use(cookieParser()); > > // Set Static Folder > app.use(express.static(path.join(__dirname, 'public'))); > > app.use('/', routes); > app.use('/users', users); > > > // Express Session > app.use(session({ > secret: 'secret', > saveUninitialized: true, > resave: true > })); > > layout.ejs > <!DOCTYPE html> > <html> > <head> > <title>LoginApp</title> > <link rel="stylesheet" href="/css/bootstrap.css" type="text/css"/> > <link rel="stylesheet" href="/css/style.css" type="text/css"/> > </head> > <%- body %> > > <footer class="footer"> > <p>© 2015 LoginApp, Inc.</p> > </footer> > </body> > </html> > > > > <https://lh3.googleusercontent.com/-ph6Wf8w1ofs/V3e1ghzvcqI/AAAAAAAAAAM/zEV_UX2YBKQidBjKsjIPaR6CtNTTXZ6gACLcB/s1600/2b8fcca7612340b495f5c8ce39225594.png> > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/3ad4137e-8fb1-4afd-b70f-893880df1a46%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
