Do you want to work on this issue?
You can request for a bounty in order to promote it!
Redirect user when trailing slash omitted or included depending on permalink settings #457
limitlessloop posted onGitHub
<!-- Please don't delete this template or we'll close your issue -->
<!-- Before creating an issue please make sure you are using the latest version of Saber. -->
<!-- Issues which contain questions or support requests will be closed. -->
<!-- Please ask questions via following several ways. -->
<!-- https://chat.saber.land/ -->
<!-- https://stackoverflow.com/questions/ask?tags=saberjs -->
Bug report
When customising a permalink Saber should honour the chosen permalink pattern. Currently, a user can visit both themes/
and theme
when a permalink is specified as page: /:slug/
. Search engines treat these two paths as different pages. Therefore it is in the best interest for SEO reasons to only allow one. A possible solution is to redirect the user when the trailing slash /
is omitted and when it is included.
Steps to reproduce
This occurs on a fresh install of Saber and also the main Saber website.
<!-- If you are reporting a bug that can ONLY be reproduced on your repository, PLEASE provide this repo link. That takes guessing work out of the way and saves us time. -->
<!-- You can also use this CodeSandbox starter https://bit.ly/2IlcpNF -->
What is expected?
Redirect the user following the permalink pattern specified in the Saber config.
For example:
// saber.config.yml
permalinks:
page: /:slug/
User enters:
// browser
saber.land/themes
Website redirects to:
// browser
saber.land/themes/
If page: /:slug
is specified it should do the opposite to the above and remove the trailing slash.
What is actually happening?
The user can visit both URLs saber.land/themes
and saber.land/themes/
both with trailing slash omitted or included, however the URL does not change. Google treats both URLs as separate pages with same content.
Other relevant information
There is some information regarding trailing slashes on the Google webmaster blog. https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html?m=1
Here is some more up-to-date information and advice regarding how to fix this using .htaccess. https://www.danielmorell.com/guides/htaccess-seo/redirects/https-www-and-trailing-slash
I'm not familiar with one-page applications, but maybe for now, this can be managed using the above method? I'll give it a go when I get chance.