Skip to content

Conversation

jesseleite
Copy link
Collaborator

@jesseleite jesseleite commented Jun 3, 2025

This PR adds the ability to enforce trailing slashes in URLs via URL::enforceTrailingSlashes(), which has been asked for a fair bit.

The idea is to make Statamic normalize trailing slashes in URLs (ie. remove them by default, or add them if the above is configured), while respecting URL query and fragment at the end of any given URL. To opt into this functionality for any URL output, simply wrap the URL with URL::tidy($url).

In fact, all methods on the URL facade should now return tidied output with normalized trailing slashes where relevant. This PR kind of turned into a big URL facade overhaul/cleanup for v6.


Related Issues:

statamic/ideas#1293
statamic/ssg#65
statamic/seo-pro#387

Related PRs:

statamic/ssg#203
statamic/seo-pro#393

@jesseleite jesseleite requested a review from jasonvarga July 10, 2025 21:17
@jesseleite jesseleite marked this pull request as ready for review July 10, 2025 21:17
@jsmit99
Copy link

jsmit99 commented Jul 24, 2025

@jesseleite @jasonvarga whats the status on this one? Would love to see it.

@jasonvarga
Copy link
Member

Will be reviewed soon

- Write a test for when home is an entry that it shouldn't be marked as is_parent when on any other page. The change to Strucure.php fixes this.
- Edit the existing test (where home is a plain non-entry link) so that home shouldn't be marked as parent on any page, except if you're on a page that is actually a child.
@jsmit99
Copy link

jsmit99 commented Jul 31, 2025

@jasonvarga is there perhaps anything I can do to help speed up this review? This PR was created almost 2 months ago.

@duncanmcclean
Copy link
Member

This PR is targeting Statamic 6, which isn't out yet. It'll be merged before v6 is released.

@jsmit99
Copy link

jsmit99 commented Jul 31, 2025

@duncanmcclean it appears to be in progress for quite a long time. Perhaps you have a solution for a site we want to migrate to statamic (v5) at this point? Changing a 10y/o site trailing slash to redirect them to without is a huge SEO risk.

@aaronbushnell
Copy link
Contributor

Hey, all! Will this be merged in to review as part of the alphas? Or will this be in a future beta release? Was hoping to get in some SEO Pro testing, but I think this is required for that.

@duncanmcclean
Copy link
Member

Not sure about timing, but it'll definitely be merged before we tag a stable release.

@jasonvarga jasonvarga merged commit 1fbc7f2 into master Sep 12, 2025
18 checks passed
@jasonvarga jasonvarga deleted the url-trailing-slashes branch September 12, 2025 14:04
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

Successfully merging this pull request may close these issues.

5 participants