Elder.js Plugin: Sitemap
Easily generate a sitemap for your Elder.js website.
By default it will build a sitemap when you build your Elder.js site.
This sitemap will include a sub-sitemap for each route.
Currently there is a hard limit of 50,000 urls per sub-sitemap.
Install
npm install --save @elderjs/plugin-sitemap
Config
Once installed, open your elder.config.js
and configure the plugin by adding @elderjs/plugin-sitemap
to your plugin object.
plugins: {
'@elderjs/plugin-sitemap': {
origin: '',
exclude: [],
routeDetails: {},
lastUpdate: {},
},
}
Configuring Route Specific Details
plugins: {
'@elderjs/plugin-sitemap': {
origin: '',
exclude: [],
routeDetails: {
home: {
priority: 1.0,
changefreq: 'monthly',
},
blog: {
priority: 0.8,
changfreq: 'monthly',
}
},
lastUpdate: {
home: '2020-01-01',
blog: async ({ query, request }) => {
return new Date(Date.now());
}
},
},
}
Exclusion Logic is Greedy
For example excluding 'green' route
exclude: ['green'],
would excude all routes starting with 'green', also 'greenland' and 'green-eggs'
'green' route could be explicitly excluded with
exclude: ['green/'],
Also nested routes or specific slugs of route could be excluded with
exclude: ['green/', 'greenland/polar-bear'],