Skip to content

Trailing slashes #1293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stuartcusackie opened this issue Jan 13, 2025 · 7 comments
Open

Trailing slashes #1293

stuartcusackie opened this issue Jan 13, 2025 · 7 comments

Comments

@stuartcusackie
Copy link

stuartcusackie commented Jan 13, 2025

Bug description

Are trailing slashes supported? I can't find a definitive answer to this in any of the existing issues or on Discord.

I have added trailing slashes to each of my collections but calling $entry->url always returns a url without a trailing slash.

Personally I can do without trailing slashes but some of my clients insist on maintaining the slash structure when switching from WordPress to Statamic.

If they are supported by Statamic then I think there is a bug.

How to reproduce

Create a collection with a trailing slash route, e.g.:
{parent_uri}/{slug}/

Call {{ $entry->url }} and noticed that trailing slashes are not visible.

Logs

No response

Environment

Laravel Version: 11.34.2
PHP Version: 8.3.15
Composer Version: 2.7.4
Version: 5.41.0 PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

@duncanmcclean
Copy link
Member

Statamic doesn't currently support trailing slashes in URLs, but it is on our roadmap:

CleanShot 2025-01-13 at 14 25 31

It doesn't look like we currently have a feature request issue open for it, so I'm going to transfer this to the ideas repo.

@carstenjaksch
Copy link

Any news? I am about to relaunch a WordPress site on Statamic and wonder if it would be possible to easily enforce trailing slashes. To add context: I would use Full Measure Static Caching.

More precisely:

  • Redirect to entry route with trailing slash.
  • Canonical should point to route with trailing slash.
  • Internal links should return the trailing slash version of a URL.

@duncanmcclean
Copy link
Member

Sorry, I don't have any news on this, or an ETA. We'll update this issue when we have any news.

@mthorsdal
Copy link

Is there a workaround for this until it will be launched? Or any news?

@jasonvarga
Copy link
Member

The workaround is to add a server rewrite rule to redirect the trailing slash url to the non-trailing slash url.

Something like this:

rewrite ^/(.*)/$ /$1 permanent;

@mthorsdal
Copy link

Thanks Jason!

We are migrating a site that depends heavily on organic search traffic within the next few months - and our SEO consultants advise against redirecting all URL's without a very good reason.

I'd be hoping to find a "quick and dirty" solution that fixes {{url}} tags as well as sitemap/hreflang/canonical etc generation, allowing us to actually be using an ending / until statamic team pushes the feature #9997 from roadmap.

@jasonvarga
Copy link
Member

If you're providing 301 redirects I don't think there's a hit to SEO. But I'm no expert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants