Index of every page on this site: llms.txt
All skills
nuxt-modules avatar

/nuxtjs-sitemap

@205a027
by Nuxt Modulesnuxt-modules/sitemap441 stars
64
Run it yourself

Generate, split, and debug XML sitemaps in a Nuxt app with the @nuxtjs/sitemap module. Use when a task mentions sitemap.xml, sitemap_index.xml, the sitemap config key, defineSitemapEventHandler, dynamic sitemap URLs from a CMS or API, multiple or chunked sitemaps, zeroRuntime, hreflang in sitemaps with @nuxtjs/i18n, defineSitemapSchema for Nuxt Content, or a page that is missing from or wrongly present in the sitemap.

  • 2 files
  • 10.8 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/nuxt-modules/sitemap/nuxtjs-sitemap

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesnuxt-content.md

≈500 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Nuxt Content v3

Tested with @nuxt/content 3.16.1.

Opt a collection in

A collection is in the sitemap only when its schema has a sitemap field from defineSitemapSchema(). A collection without it is left out, with no warning.

// content.config.ts
import { defineCollection, defineContentConfig } from '@nuxt/content'
import { defineSitemapSchema } from '@nuxtjs/sitemap/content'
import { z } from 'zod'

export default defineContentConfig({
  collections: {
    blog: defineCollection({
      type: 'page',
      source: 'blog/**/*.md',
      schema: z.object({
        draft: z.boolean().optional(),
        sitemap: defineSitemapSchema({
          name: 'blog', // must equal the collection key
          filter: entry => !entry.draft,
          onUrl: (url) => {
            url.loc = url.loc.replace('/blog/', '/articles/')
          },
        }),
      }),
    }),
  },
})

Put @nuxtjs/sitemap before @nuxt/content in modules. The module warns if the order is wrong. asSitemapCollection() is deprecated. Use defineSitemapSchema() in the schema.

Frontmatter

---
sitemap:
  lastmod: 2024-01-15
  priority: 0.9
---

sitemap: false in frontmatter removes the page. So does robots: false, or a robots string with noindex or none, such as robots: noindex, nofollow. The schema does not need a robots field.

Traps

  • filter and onUrl run as source text in the server bundle. A variable, import, or helper from outside the callback does not exist there. The build fails with "The filter callback of collection "blog" reads HIDDEN from outside the callback". Move the value inside the callback. Arrows, function expressions, and method shorthand all work.
  • filter or onUrl without name fails the build with "name is required when using filter or onUrl".
  • Serverless deploys can lose content URLs when the content database is not readable at runtime. Prerender the sitemap, or configure a runtime database.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 205a027. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 weeks ago.

Activeupdated last month
Other metadata
compatibility
Requires Node.js ^22.22.3 || ^24.15.0 || >=26.0.0. Requires Nuxt ^4.6.0 || ^5.0.0.

README badge

README badge for nuxt-modules/sitemap