Keystone错误404“在此地址找不到页面(404)”

时间:2016-05-19 20:37:42

标签: javascript node.js mongodb pug keystone

我在localhost上运行我的keystone网站,我正在尝试使用新网站创建一个新的导航链接,但是我收到一条错误,指出链接后面的地址无法找到。

链接显示在导航栏中。

我使用以下代码在/routes/views/aboutme.js中创建了一个文件:

    var keystone = require('keystone');

exports = module.exports = function (req, res) {

    var view = new keystone.View(req, res);
    var locals = res.locals;

    // locals.section is used to set the currently selected
    // item in the header navigation.
    locals.section = 'aboutme';

    // Render the view
    view.render('aboutme');
};

使用代码在/templates/views/aboutme.jade文件中添加.jade:

    extends ../layouts/default

block content
        h1 xyz
        p xyzxyzyxzxyzxyzyxzzxyz
        p xyzxyzyxzxyzxyzyxzzxyz
        p xyzxyzyxzxyzxyzyxzzxyz

为什么无法找到该页面? :/

1 个答案:

答案 0 :(得分:0)

我自己找到了答案。 对于具有相同问题的每个人,在/ routes文件夹中都有index.js文件。 在这段代码中:

    // Setup Route Bindings
exports = module.exports = function (app) {

}

在大括号之间你必须编写以下代码:

app.get('/name', routes.views.name);

"名称"是你新的网站名称。