Want to know why you might need this module? Check out the introduction.
To get started with Nuxt Sitemap, you need to install the dependency and add it to your Nuxt config.
npx nuxt module add @nuxtjs/sitemapnpm i @nuxtjs/sitemapYou will need to manually add the module to your Nuxt config.
export default defineNuxtConfig({
modules: [
'@nuxtjs/sitemap',
],
})
yarn add @nuxtjs/sitemapYou will need to manually add the module to your Nuxt config.
export default defineNuxtConfig({
modules: [
'@nuxtjs/sitemap',
],
})
pnpm i @nuxtjs/sitemapYou will need to manually add the module to your Nuxt config.
export default defineNuxtConfig({
modules: [
'@nuxtjs/sitemap',
],
})
bun i @nuxtjs/sitemapYou will need to manually add the module to your Nuxt config.
export default defineNuxtConfig({
modules: [
'@nuxtjs/sitemap',
],
})
After you've set up the module with the minimal config, you should be able to visit /sitemap.xml to see the generated sitemap.
You may notice that the URLs point to your localhost domain, this is to make navigating your local site easier, and will be updated when you deploy your site.
All pages preset are discovered from your Application Sources, for dynamic URLs see Dynamic URLs.
You can debug this further in Nuxt DevTools under the Sitemap tab.
At a minimum the module requires a Site URL to be set, this is to only your canonical domain is being used for the sitemap. A site name can also be provided to customize the sitemap stylesheet.
export default defineNuxtConfig( site: { url: 'https://example.com', name: 'My Awesome Website' }, }) NUXT_SITE_URL=https://example.comNUXT_SITE_NAME=My Awesome WebsiteTo ensure search engines find your sitemap, you will need to add it to your robots.txt. It's recommended to use the Nuxt Robots module for this.
Every site is different and will require their own further unique configuration, to give you a head start:
You do not need to worry about any further configuration in most cases, check the best practices guide for more information.
You've successfully installed Nuxt Sitemap and configured it for your project.
Documentation is provided for module integrations, check them out if you're using them.
Once you're ready to go live, check out the Submitting Your Sitemap guide.