question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trailing slash option

See original GitHub issue

Heyo 👋

it’d be great to have an option for adding/removing trailing slashes for routes coming from localePath. A global setting would suffice IMO and could be applied around the marked lines.

https://github.com/nuxt-community/nuxt-i18n/blob/617e31e8235ffdeb7d345c3b960701b616d94b72/src/plugins/routing.js#L47-L48

trailingSlashes: true

/abc/ -> /abc/ (keeps the same) /abc -> /abc/ (changes)

trailingSlashes: false

/abc -> /abc (keeps the same) /abc/ -> /abc (changes)

trailingSlashes: undefined (default)

/abc/ -> /abc/ (keeps the same) /abc -> /abc (keeps the same)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
gangsthubcommented, Oct 25, 2019

Thanks, @manniL! Solved since Nuxt v2.10.0 👏

0reactions
kedrzucommented, Jun 21, 2021

I think, that what @timothymarois meant, was that when you set trailingSlashes: false option in Nuxt router settings, there is this weird behavior: Suppose I use prefix strategy and have 2 locales: pl and en. When I go into /pl I am redirected to /pl/ (slash added) and get 404, since trailing slashes are disabled. A workaround would be to set trailingSlashes: undefined. In that case /pl is still redirected to /pl/, but this time it works (since trailing slash is optional). But this may be not good in terms of SEO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a trailing slash? - Ryte Wiki
A trailing slash is the forward slash placed at the end of a URL. The trailing slash is generally used to mark a...
Read more >
Integrated handling of trailing slashes in Gatsby #34205
Introduce the option to force trailing slashes for all routes (including client routes) likely through a config setting in gatsby-config.js ...
Read more >
Trailing Slashes and Gatsby - Jon
The reason I say that Gatsby implies we should use trailing slashes is because Gatsby directory-izes path s you give to createPage() ....
Read more >
Should You Have a Trailing Slash at the End of URLs? - Ahrefs
A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. But should you...
Read more >
gatsby-plugin-force-trailing-slashes
A web-server that treats trailing-slash paths as directories with an index.html inside and non-trailing-slash paths as named documents (and ideally redirects ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found