Skip to content

[Feature] Prevent duplicated content on generated routes #3100

@MitsuhaKitsune

Description

@MitsuhaKitsune

Hi,

Actually when I let nuxt to generate the routes automatically with my pages folder, it generate all routes without final trailing slash '/' for example news, but still accesible on url with http://localhost:3000/news and http://localhost:3000/news/ (both are the same route), this is a bad practice for SEO, the search engines detect it as duplicated content.

To prevent it, the vue-router allow set pathToRegexpOptions: { strict: true } option on routes that only meet the match if the path are exactly the same that defined on route, if i set the path as /news/ I only can access it with http://localhost:3000/news/ and can't with http://localhost:3000/news (show 404)

As I read on some SEO guides, the final trailing slash represent a directory for search engines, in other words, have more subpages, applied to nuxt, it can be achieved putting the final slash for each pages subdirectories and without final slash for each vue file.

Example scenario

Files:

pages/
 |-index.vue
 |-contact.vue
 |-blog/
 |   |-index.vue
 |   |-_slug.vue
 |-otherpages/
    |-index.vue
    |-one.vue
    |-two.vue

Generated routes urls (should match exactly, any diference on path didnt meet the route, except the fourth url that it's dinamic but still working only without final slash):

/
/contact
/blog/
/blog/somedinamicslug
/otherpages/
/otherpages/one
/otherpages/two
This question is available on Nuxt community (#c2684)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions