Install Nuxt Sitemap
- Nuxt Redirects
- Nuxt Google Search Console
- Nuxt Internal Links
- Nuxt SEO Analyze
Setup Module
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 nuxi module add @nuxtjs/sitemap
npm i @nuxtjs/sitemap
You will need to manually add the module to your Nuxt config.
export default defineNuxtConfig({
modules: [
'nuxt-og-image',
],
})
yarn add @nuxtjs/sitemap
You will need to manually add the module to your Nuxt config.
export default defineNuxtConfig({
modules: [
'nuxt-og-image',
],
})
pnpm i @nuxtjs/sitemap
You will need to manually add the module to your Nuxt config.
export default defineNuxtConfig({
modules: [
'nuxt-og-image',
],
})
bun i @nuxtjs/sitemap
You will need to manually add the module to your Nuxt config.
export default defineNuxtConfig({
modules: [
'nuxt-og-image',
],
})
Verifying Installation
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.
Configuration
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_PUBLIC_SITE_URL=https://example.comNUXT_PUBLIC_SITE_NAME=My Awesome Website
To 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:
- Dynamic URL Endpoint - If you have dynamic URLs you need to add to the sitemap, you can use a runtime API endpoint. For example, if your generating your site from a CMS.
- Multi Sitemaps - If you have 10k+ pages, you may want to split your sitemap into multiple files so that search engines can process them more efficiently.
You do not need to worry about any further configuration in most cases, check the best practices guide for more information.
Next Steps
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.
- Nuxt I18n - Automatic locale sitemaps.
- Nuxt Content - Configure your sitemap entry from your markdown.
Once you're ready to go live, check out the Submitting Your Sitemap guide.