Open marcoeh opened 3 years ago
Trailing slashes are a pain point for the Nuxt team and one member even considered dropping the trailingSlash option for Nuxt 3 (but I don't think they'll follow through). If you look for trailingSlash in the Nuxt repo, you can find many issues. I personally experienced problems with nuxt-child routes and static payloads. Reading through issues threads, I saw that tests are sometimes missing for routes ending with trailing slashes.
In Netlify, like @marcoeh mentioned, it's possible to disable the forced redirection to the trailing slash. However, it's currently impossible to have Netlify redirect examle.com/about/
to examle.com/about
. But if everything is setup correctly, it should be unlikely for users or web crawlers to visit examle.com/about/
.
Someone also wrote a great post about this topic 😏
tl;dr Both versions get tracked…
es isch biz tricky mit trailing slashes, es werded denn halt beidi versione tracked uf matomo. somit erschiint example.com/about uf matomo als about und example.com/about/ als about/index . dem chönnti mer biz entgegestüüre wenn mer usefindet wie mer mitem nuxt/matomo module die default wert überschriibt wos übermittled und dete trailing slashes stripped oder forciert. das gseht denn so us wie bi fischer:
Did you want to alter the historical data or fix this for future tracking? Historical data can't be altered unfortunately. You can delete old data with the GDPR tool. For the future you can set a custom URL in the tracker with _paq.push(['setCustomUrl', 'customHomepageURL']);
Make a PR for nuxt-matomo that adds an option to strip or force trailing slashes before the request to matomo is being fired. See this line.
I opened up a pull request.
Some info about redirects in nuxt: https://deltener.com/blog/nuxt-redirects/
True HTTP Status Codes When Using Nuxt Generate It’s common to use Nuxt to create super fast JAMStack sites. In these cases serverMiddleware isn’t available since you are running generate. If you want server-side redirects with real HTTP status codes you have to use whatever methods your hoster has. Here are the methods for Netlify and Zeit
We should decide whether we want trailing slashes in our urls or not (or add a config option). So we can force trailing slashes or remove them. There should be 301 redirects in place.
Things to consider:
vue-link
to render link fields from craft, there is an option to add or remove trailing slashes by usingForNuxtAddSlash
orForNuxtStripSlash
respectively.nuxt-link
s should point to the correct versiontrailingSlashes: false/true
and use it project-wide instead of adding custom configs everywhere this has to be configured.