Technology News

Trailing Slashes on URLs: Contentious or Settled?

A fun deep dive from Zach. Do you have an opinion on which you should use?

1) https://website.com/foo/
2) https://websites.com/foo

The first option has a “trailing slash.” The second does not.

I’ve always preferred this thinking: you use a trailing slash if that page has child pages (as in, it is something of a directory page, even if has unique content of its own). If it’s the end-of-the-line (of content), no trailing slash.

I say that, but this very site doesn’t practice it. Blog posts on this site are like css-tricks.com/blog-post/ with a trailing slash and if you leave off the trailing slash, WordPress will redirect to include it. That’s part of the reason Zach is interested here. Redirects come with a performance penalty, so it’s ideal to have it happen as infrequently possible.

Performance is one thing, but SEO is another one. If you render the same content, both with and without a trailing slash, that’s theoretically a duplicate content penalty and a no-no. (Although that seems weird to me, I would think Google would smart enough not to be terribly concerned by this.)

Where resources resolve to seems like the biggest deal to me. Here’s Zach:

If you’re using relative resource URLs, the assets may be missing on Vercel, Render, and Azure Static Web Apps (depending on which duplicated endpoint you’ve visited).

<img src="image.avif"> on /resource/ resolves to /resource/image.avif

<img src="image.avif"> on /resource resolves to /image.avif

That’s a non-trivial difference and, to me, a reason the redirect is worth it. Can’t be having a page with broken resources for something this silly.

What complicates this is that the site-building framework might have opinions about this and a hosting provider might have opinions about this. As Zach notes, there are some disagreements among hosts, so it’s something to watch for.

Me, I’d go with the grain as much as I possibly could. As long as redirects are in place and I don’t have to override any config, I’m cool.

Direct Link →

Is the cyberwar coming or is it already here?
Top 10 Best PLR(Private Label Rights) Websites | Which One You Should Join in 2022?

Related Articles

Tips for Successful Cold Calling

Tips for Successful Cold Calling
Cold calling can be daunting but it can yield amazing results if done right. While it hasn’t had a great reputation, cold calling isn’t dead. This survey by Rain Group…

The Big Predictions for SEO in 2023

The Big Predictions for SEO in 2023
SEO is an industry that is changing extremely quickly. In some respects, these changes are lightning-fast, causing a whole bunch of headaches for SEOs like myself. Other elements of SEO…

Pure CSS Bezier Curve Motion Paths

Pure CSS Bezier Curve Motion Paths
Are you a Bezier curve lover like I am? Besides being elegant, Bezier curves have nice mathematical properties due to their definition and construction. No wonder they are widely used…

CSS “decorations”

css-decorations
A reader wrote to me the other day asking about this bit of CSS they came across in Wikipedia’s Common.css: .mw-collapsible-leftside-toggle .mw-collapsible-toggle { /* @noflip */ float: left; /* @noflip */…