npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nuxt-basic-sitemap

v0.5.0

Published

Basic sitemap module for Nuxt

Readme

Nuxt Basic Sitemap

Overview

Nuxt Basic Sitemap is a developer-friendly module for generating sitemaps in Nuxt applications. It simplifies the process of creating dynamic and static sitemaps, ensuring your website is SEO-friendly and easily discoverable by search engines.

Features

  • Static pages support: Automatically include static pages based on your application's routes in your sitemap effortlessly.
  • Include any page: Include any other pages, via static array, or sync/async function
  • Exclusion rules: Exclude specific pages or routes from the sitemap.
  • Trailing slash handling: Configure trailing slashes for URLs.
  • Custom hostname: Set a custom hostname for your sitemap.
  • Highly configurable: Fine-tune sitemap generation with various options.

Installation

Install the module via npm:

npm install nuxt-basic-sitemap

Or using yarn:

yarn add nuxt-basic-sitemap

Usage

  1. Add the module to your Nuxt configuration:
export default defineNuxtConfig({
  modules: [
    'nuxt-basic-sitemap',
  ],
  basicSitemap: {
    hostname: 'https://example.com',
    exclude: ['/to-exclude'],
    trailingSlash: true,
  },
});
  1. Start your Nuxt application, and the sitemap will be available at /sitemap.xml.

Configuration Options

enabled

  • Type: boolean
  • Default: true
  • Description: Ability to quickly turn off/on sitemap

hostname

  • Type: string
  • Required: false - if no hostname set, module will try to get host from a request
  • Description: The base URL for your sitemap.

trailingSlash

  • Type: boolean
  • Default: false
  • Description: Whether to add trailing slashes to URLs.

includeStaticPages

  • Type: boolean
  • Default: true
  • Description: Whether to automatically add pages based on your app's routes

exclude

  • Type: string[]
  • Required: false
  • Description: An array of routes to exclude from the sitemap.

include

  • Type: Array<string | SitemapItem> | (() => Array<string | SitemapItem>) | (() => Promise<Array<string | SitemapItem>>)
  • Required: false
  • Description: An array of routes to includes pages. Can be just simple array of strings and SitemapItem objects, or a function that returns either same array, or promise, that will resolve the same array.

More about SitemapItem type here

staticPagesOptions

  • Type: Array<SitemapItem>
  • Required: false
  • Description: Ability to set lastmod, changefreq and priority for static pages (pages that automatically generates based on routes)

More about SitemapItem type here

Types

SitemapItem

type SitemapItem = {
  url: string;
  lastmod?: string;
  changefreq?: Changefreq;
  priority?: number;
};

Example

Basic example

// nuxt.config.ts
{
...
  basicSitemap: {
    hostname: 'https://example.com',
    trailingSlash: true,
    include: [
      '/about',
      {
        url: '/blog',
        changefreq: 'daily'
      }
    ],
    exclude: ['/to-exclude']
  }
...
}

Example with options for static pages

// nuxt.config.ts
{
...
  basicSitemap: {
    hostname: 'https://example.com',
    staticPagesOptions: [
      {
        url: '/',
        priority: 1
      }
    ]
  }
...
}

Example with only dynamic custom pages

// nuxt.config.ts
{
...
  basicSitemap: {
    hostname: 'https://example.com',
    includeStaticPages: false,
    include: async () => {
      const pages = await $fetch(...);

      return pages;
    }
  }
...
}

Development

Running the Playground

The playground directory contains a sample Nuxt application for testing the module. To run the playground:

cd playground
npm install
npm run dev

Running Tests

The test directory contains unit tests for the module. To run the tests:

npm test

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a clear description of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

If you encounter any issues or have questions, feel free to open an issue on GitHub or contact the maintainers.


Happy coding!