harlan-zw / nuxt-seo

The complete SEO solution for Nuxt.
https://nuxtseo.com
949 stars 56 forks source link

Do we need to take care of the query params? #253

Open kissu opened 1 week ago

kissu commented 1 week ago

Details

I saw this question today on StackOverflow, asking how to exclude query params.

I am not sure if the OP there is using this module, but after a quick search in the docs, I saw this for Yandex, hence I was wondering if that thing is not needed for Google too, or if this module that care of that part by itself (I'm not sure if OP is currently using this module).

If this is not handled by this module by default, do you have a way of doing things? 🤗

harlan-zw commented 6 days ago

It looks like the user in the comment is using the Nuxt v2 module so can't help too much there (it's a different maintainer / code base).

In Nuxt SEO's sitemap module you can filter paths using regex so should be pretty straightforward https://nuxtseo.com/sitemap/guides/filtering-urls#filter-urls-with-include-exclude.

Although I'd question how the param paths are getting added anyway :thinking:

export default defineNuxtConfig({
  sitemap: {
    exclude: [/\?.+/], 
})

If this doesn't work users always have access to hooks that can modify the final output https://nuxtseo.com/sitemap/nitro-api/nitro-hooks

kissu commented 6 days ago

I am confused as for the different module. Isn't OP using the correct module? Do you find that the syntax is different or something, how do you know it's the other one? And which one?

Yes, that's what I thought regarding the regex part. No need to have anything more complex. 👌🏻

As for the query strings, I guess that URL params are better and more common for the SEO/sitemap part but I guess that this is how OP is doing it so far by having different result for each use-case haha.