João Cerqueira
João Cerqueira

Reputation: 563

Node, express and jade: not loading css stylesheets

I just started a small project in node and express using jade as the view engine but it isn't working for some reason that I don't know...

My view:

doctype html
html
  head
    meta(charset='utf-8')
    title= 'Admin / ' + title
    link(ref='stylesheet', href='https://storage.googleapis.com/code.getmdl.io/1.0.5/material.indigo-pink.min.css')
    link(ref='stylesheet', href='/public/css/style.css')
   body
     block content
     script(src='/public/material-design-lite/material.min.js')

I've used the mdl stylesheet from the official source to be sure that it wasn't a problem with my static folder route.

My Controller:

export default class Dashboard {
    constructor(req, res) {
        res.render('admin/dashboard', {
            title: 'Dashboard'
        });
    }
}

The Core:

import express from 'express';
import {Routes} from './config/config';

export default class Core {
    constructor() {
        this.app = express();

        this.app.set('view engine', 'jade');
        this.app.set('views', __dirname + '/views');

        let routes = new Routes();
        this.app.use('/', routes.get());
        this.app.use('/public', express.static('public'));
        this.app.use('/public/material-design-lite', express.static('node_modules/material-design-lite'));

        this.app.listen('3000', () => {
            console.log('Listening on ::3000');
        });
    }
}

I don't see anything wrong but somehow the stylesheets aren't loading, however the script is loading fine and if I try to load the stylesheets directly they load just fine too.

Please, if anyone could help me I'd appreciate a lot!

Thanks in advance.

Upvotes: 0

Views: 557

Answers (1)

Pero P.
Pero P.

Reputation: 26982

It should be rel not ref

link(rel='stylesheet', href='/public/css/style.css')
     ^^^

Upvotes: 2

Related Questions