![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@nuxtjs/sitemap
Advanced tools
Automatically generate or serve dynamic sitemap.xml for Nuxt.js projects
Automatically generate or serve dynamic sitemap.xml for Nuxt.js projects!
Add the @nuxtjs/sitemap
dependency with yarn
or npm
to your project.
Add @nuxtjs/sitemap
to the modules
section of nuxt.config.js
:
modules: [
'@nuxtjs/sitemap'
]
notice: If you use other modules (eg.
nuxt-i18n
), always declare the sitemap module at end of array (eg.modules: ['nuxt-i18n', '@nuxtjs/sitemap']
)
{
modules: [
'@nuxtjs/sitemap'
],
sitemap: {
hostname: 'https://example.com',
gzip: true,
exclude: [
'/secret',
'/admin/**'
],
routes: [
'/page/1',
{
url: '/page/2',
changefreq: 'daily',
priority: 1,
lastmodISO: '2017-06-30T13:30:00.000Z'
}
]
}
routes
[]
or generate.routes
value from your nuxt.config.js
The routes
parameter follows the same way than the generate
configuration.
See as well the routes examples below.
path
(optional)/sitemap.xml
The URL path of the generated sitemap.
hostname
(optional)sitemap.hostname
value from your nuxt.config.js
build.publicPath
value from your nuxt.config.js
os.hostname()
for generate or spa mode, or dynamically based on request URL (headers.host
) for universal modeThis value is mandatory for generation sitemap file, and you should explicitly provide it for generate or spa mode.
cacheTime
(optional)1000 * 60 * 15
(15 Minutes)Defines how frequently should sitemap routes being updated.
Please note that after each invalidation, routes
will be evaluated again. (See routes section)
exclude
(optional)[]
The exclude
parameter is an array of glob patterns to exclude static routes from the generated sitemap.
filter
(optional)undefined
If filter
option is set as a function, all routes will be filtered through it.
Examples:
// nuxt.config.js
// Filter routes by language
{
sitemap: {
filter ({ routes, options }) {
if (options.hostname === 'example.com') {
return routes.filter(route => route.locale === 'en')
}
return routes.filter(route => route.locale === 'fr')
}
}
}
// Add a trailing slash to each route
{
sitemap: {
filter ({ routes }) {
return routes.map(route => route.url = `${route.url}/`)
}
}
}
gzip
(optional)false
Enable the creation of the .xml.gz
sitemap compressed with gzip.
xmlNs
(optional)undefined
Set the XML namespaces by override all default xmlns
attributes in <urlset>
element.
// nuxt.config.js
{
sitemap: {
xmlNs: 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'
}
}
xslUrl
(optional)undefined
The URL path of the XSL file to style the sitemap.
defaults
(optional){}
The defaults
parameter set the default options for all routes.
// nuxt.config.js
{
sitemap: {
defaults: {
changefreq: 'daily',
priority: 1,
lastmod: new Date(),
lastmodrealtime: true
}
}
}
See available options: https://github.com/ekalinin/sitemap.js#usage
By default, the dynamic routes are ignored by the sitemap module.
Nuxt cannot automatically provide this type of complex routes.
Example:
-| pages/
---| index.vue --> static route
---| about.vue --> static route
---| users/
-----| _id.vue --> dynamic route
If you want the module to add any route with dynamic parameters, you have to set an array of dynamic routes.
eg. add routes for /users/:id
in the configuration:
// nuxt.config.js
{
sitemap: {
routes: [
'/users/1',
'/users/2',
'/users/3'
]
}
}
// nuxt.config.js
const axios = require('axios')
{
sitemap: {
routes () {
return axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => res.data.map(user => '/users/' + user.username))
}
}
}
This feature is deprecated. Use a promise-based approach instead.
// nuxt.config.js
const axios = require('axios')
{
sitemap: {
routes (callback) {
axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => {
let routes = res.data.map(user => '/users/' + user.username)
callback(null, routes)
})
.catch(callback)
}
}
}
FAQs
Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.
The npm package @nuxtjs/sitemap receives a total of 69,267 weekly downloads. As such, @nuxtjs/sitemap popularity was classified as popular.
We found that @nuxtjs/sitemap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.