meanjs / mean-seo

SEO Solution for MEAN.JS applications using PhantomJS.
72 stars 36 forks source link

could not understand where should I put app.use(...). #3

Open AttilaSATAN opened 10 years ago

AttilaSATAN commented 10 years ago

If I'm mistaken please correct me but isn't app.use(app.router) removed from Express 4.

https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x

And if I'm not mistaken again, MEAN is using Exp. 4 Therefore there is no line of app.use(app.router)

then where should I put app.use(seo...)?

app.use(seo({
    cacheClient: 'disk', // Can be 'disk' or 'redis'
    cacheDuration: 2 * 60 * 60 * 24 * 1000, // In milliseconds for disk cache
}));

// app.use(app.router) will be below this line 
maciekpaprocki commented 10 years ago

I also just spend few hours trying to solve that. Is there any way to get update on instruction? is it even working with new express version?

I would highly appreciate some help.

wesleyfsmith commented 9 years ago

Same problem here, I'd love to know where to put the app.use() line. Thanks!

apitts commented 9 years ago

I too am struggling to work out where to put mean-seo in express.js post the upgrade to express 4.0. I have added in here:

// Setting the app router and static folder
app.use(express.static(path.resolve('./public')));

//See https://github.com/meanjs/mean-seo
app.use(seo({
cacheClient: 'disk', // Can be 'disk' or 'redis'
cacheDuration: 2 * 60 * 60 * 24 * 1000, // In milliseconds for disk cache
}));

// Globbing routing files
config.getGlobbedFiles('./app/routes/**/*.js').forEach(function(routePath) {
    require(path.resolve(routePath))(app);
});

However, mean-seo does not seem to be working as Google is still not caching my page - a search for Polinode and checking cached shows a blank page.

wesleyfsmith commented 9 years ago

@apitts, that is the correct place to add it. It's working for me. It took a while before google updated the search results.

If you sign up for the google webmaster tools, you can append the escaped fragment to the end of your website url and see if you are getting results. If so, it is working and will just take time for your ranking to improve in my experience.

apitts commented 9 years ago

Thanks @wesleyfsmith - appreciate it! Yep - I think my issue was actually SSL related, which is fixed now. It's still not rendering all my content so have another issue to solve yet...but certainly getting closer.

imomin commented 9 years ago

This is what I did and it seems to be working.... when I do curl http://localhost:9000/users/1?_escaped_fragment_=

// Setup server var app = express(); var server = require('http').createServer(app); var socketio = require('socket.io')(server, { serveClient: (config.env === 'production') ? false : true, path: '/socket.io' }); require('./config/socketio')(socketio); require('./config/express')(app);

app.use(seo({ cacheClient: 'disk', // Can be 'disk' or 'redis' cacheDuration: 2 * 60 * 60 * 24 * 1000, // In milliseconds for disk cache }));

require('./routes')(app); require('./config/conference')(app,socketio);

kybarg commented 7 years ago

/config/lib/express.js Before module.exports.init = function (db) { ~ line 220

/**
 * Configure seo See https://yandex.ru/support/webmaster/robot-workings/ajax-indexing.xml
 */
module.exports.initModulesSeo = function (app) {
  app.use(seo({
    cacheClient: 'disk', // Can be 'disk' or 'redis'
    cacheDuration: 0 // In milliseconds for disk cache
  }));
};

Then before this.initModulesServerRoutes(app);

this.initModulesSeo(app);