Where is title or app name for sails.js (using node.js and express.js)?

▼魔方 西西 提交于 2019-11-29 14:30:52

问题


I'm trying to change my websites name. Can't find where I can set title or app name.


回答1:


You can create any file in config/ directory, for example config/app.js which contains comething like this:

module.exports = {
    appName : 'My App'
};

Any property of exported object become an option of Sails` config.

appName property is used as application title. For example, in default layout:

<title><%- title %></title>

where title === sails.config.appName === 'My App'

By default appName config variable is set to 'Sails'.




回答2:


I've got a good answer at the sails github issues#768.

Adding app name at the app.js and bootstrap.js file works fine for me.




回答3:


To customise your app's name simply add the following to the module.exports = { … } block in the file config/local.js

appName : 'My Brilliant App',

You can also override the page's title within your controller by passing in your own title value to the view renderer.

res.view({title: 'My brilliant title'});

and, to be SEO friendly, in your jade template specify

head
  title= sails.config.appName + " | " + title



回答4:


As of Sails 1.2.2, you may change the app name in \views\layouts\layout.ejs on line 4: <title>Your App Name</title>.



来源:https://stackoverflow.com/questions/18292415/where-is-title-or-app-name-for-sails-js-using-node-js-and-express-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!