GenomeUS / keystone-express-sitemap

Dynamic sitemap generation for applications built on KeystoneJS
19 stars 15 forks source link

Sitemap randomly misses urls #4

Open blugri opened 8 years ago

blugri commented 8 years ago

The sitemap generated by keystone-express-sitemap is alway missing random urls. The urls that are missing changes over time.

Used implementation:

// Setup Route Bindings
exports = module.exports = function(app) {
    // Sitemap
    app.get('/sitemap.xml', function(req, res) {
            sitemap.create(keystone, req, res);
        });

    // Views
    app.get('/', routes.views.index);
    app.get('/about', routes.views.about);
    app.get('/app/:app', routes.views.app);
    app.get('/blog/:category?', routes.views.blog);
    app.get('/blog/post/:post', routes.views.post);
    app.get('/cookiepolicy', routes.views.cookie);
    app.get('/privacy/:language', routes.views.privacy);
};
s-plum commented 8 years ago

Can you please provide examples of URLs that go missing? Are there any URLs that are never missing?

blugri commented 8 years ago

It looks like the root url, about and cookiepolicy are never missing (i.e. the urls without paramaters). All the other type of urls have missing ones.

I cannot find a pattern in it.

It does not change on every request. But from time to time the urls are changing. Without any changes (code and content) to the site I had these results:

monday: 15 urls tuesday: 35 urls wednesdag: 28 urls

Cheers Tom

s-plum commented 8 years ago

A few questions to help debug:

blugri commented 7 years ago

Hi,

sorry for the late reply.

`var keystone = require('keystone'); var Types = keystone.Field.Types;

/**

var Post = new keystone.List('Post', { map: { name: 'title' }, autokey: { path: 'slug', from: 'title', unique: true } });

Post.add({ title: { type: String, required: true }, state: { type: Types.Select, options: 'draft, published, archived', default: 'draft', index: true }, author: { type: Types.Relationship, ref: 'User', index: true }, publishedDate: { type: Types.Date, index: true, dependsOn: { state: 'published' } }, image: { type: Types.CloudinaryImage }, content: { brief: { type: Types.Html, wysiwyg: true, height: 150 }, extended: { type: Types.Html, wysiwyg: true, height: 400 } }, categories: { type: Types.Relationship, ref: 'PostCategory', many: true } });

Post.schema.virtual('content.full').get(function() { return this.content.extended || this.content.brief; });

Post.defaultColumns = 'title, state|20%, author|20%, publishedDate|20%'; Post.register();`

Cheers Tom

lomegg commented 6 years ago

I can confirm that this is happening indeed. A lot. Had to switch back to static sitemap because can't afford to have 70% of the urls missing randomly.

lomegg commented 6 years ago

Strangely that only happening in production. For example,

filters: {
    'Page': function(page) {
        console.log('page', page.title.en, 'state:', page.state, 'returning', page.state == 'published');
        return page.state == 'published';
    }
}

The console.log was never called in production, though some of the Page related urls were processed.

rodoflho commented 6 years ago

I also confirm. But in my case, all the dynamic URL's are missing, excepting one. I can assure I followed the guidelines. To get sitemap ok again, i have to restart server, but after some time the problem comes back.

Unfortunately, I can't recommend this Library. Instead, use npm sitemap and add your urls manually.