Nuxt.js: trailingSlash and redirects

Created on 2 Feb 2020  路  3Comments  路  Source: nuxt/nuxt.js

What problem does this feature solve?

Right now if you force trailingSlash to true, all your url's will be appended a trailing slash, which is a good feature to have for SEO. But the downside of this is that if somebody links to https://example.com/directory and you have trailingSlash set to true, it will give a 404 error (thus removing all the link juice from a SEO perspective, which is bad). As people generally don't pay much attention to trailing slashes when linking, it would be awesome if this feature would offer a redirect option.

What does the proposed changes look like?

All people going to https://example.com/directory would be redirected to https://example.com/directory/ when trailingSlash set to true.

feature-request

Most helpful comment

redirects: true sounds like a nice idea 馃憤馃徎

All 3 comments

That's the trade-off (also documented in the PR and the pages).

Your webserver or hoster (e.g. Netlify) should have configurations for that, otherwise you can use sth. like https://github.com/nuxt-community/redirect-module

The point is that is very cumbersome to actually write a redirect from non-slash to slash as there are some quirks when you deal with parameters. I have tried with redirect-module, but still haven't found a way to handle property all cases (https://stackoverflow.com/questions/56100693/nuxt-js-add-trailing-slash-to-urls-with-params)

If you already have implemented the logic for the url creation, maybe it could also be used to deal with redirects. It would be awesome if trailingSlash could have an option like redirects:true (and I think it would really fit there).

redirects: true sounds like a nice idea 馃憤馃徎

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bimohxh picture bimohxh  路  3Comments

vadimsg picture vadimsg  路  3Comments

gary149 picture gary149  路  3Comments

vadimsg picture vadimsg  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments