Sitemap
Getting Started
Install Nuxt Sitemap
Get started with Nuxt Sitemap by installing the dependency to your project.
- Install
@nuxtjs/sitemap
dependency to your project:
npx nuxi@latest module add sitemap
- Set Site Config
It's recommended to always set a canonical site URL to avoid duplicate content issues.
You can set your site URL in many ways, the easiest is nuxt.config
or .env
:
While optional, it's also recommended to set a name
as this will be displayed on your sitemap.
export default defineNuxtConfig({
site: {
url: 'https://example.com',
name: 'My Awesome Website'
},
})
Sitemap URLs will have their trailing slashes removed by default. If you want to keep them, you can set the trailingSlash
option to true
:
nuxt.config.ts
export default defineNuxtConfig({
site: {
// optional: only if you have trailing slashes enabled
trailingSlash: true
},
})
- Preview your Sitemap
After you've set up the module, if you visit /sitemap.xml
you can see the generated sitemap.
This has been generated with Application Sources.
- Next Steps
- You may want to add your own sources, see Dynamic URLs.
- Have 1000's of pages? Consider using Multiple Sitemaps.
- Ready to go Live? See Submitting Your Sitemap.