Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

How to exclude URLs? #21

Open
eggnstone opened this issue Dec 16, 2022 · 3 comments
Open

How to exclude URLs? #21

eggnstone opened this issue Dec 16, 2022 · 3 comments

Comments

@eggnstone
Copy link

Even with

sitemap: {
        routes: []
    }

the site seems to be crawled and many URLs are put into the sitemap, some of which I don't want, e.g. 200.html and 404.html.
How can I filter out these URLs?

@eggnstone
Copy link
Author

eggnstone commented Dec 17, 2022

I found one way:

sitemap: {
    hostname: 'https://example.com',
    filter: (data: any) =>
    {
        const routes = data['routes'];
        // do filtering
        return routes;
    }
}

@XenBG
Copy link

XenBG commented Dec 17, 2022

Here's the official way to exclude pages or files you don't want to include in your sitemap.xml file:

nuxt.config.ts

export default defineNuxtConfig({
    modules: [
        [
            '@funken-studio/sitemap-nuxt-3',
            {
                generateOnBuild: true,
                hostname: process.env.VITE_APP_URL,
                cacheTime: 1,
                exclude: ['/category', '/200.html', '/404.html'],
                defaults: {
                    changefreq: 'daily',
                    priority: 1,
                    lastmod: new Date().toISOString()
                }
            }
        ]
    ]
})

@eggnstone
Copy link
Author

Thank you!

This also solves my problem with

 modules: [
    '@funken-studio/sitemap-nuxt-3',
],
sitemap: {

showing errors because sitemap is not part of defineNuxtConfig.

But neither exclude nor putting it in modules seems to be documented.
Should we keep this issue open or rename it until the doc is updated?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants