+201223538180

Web site Developer I Advertising and marketing I Social Media Advertising and marketing I Content material Creators I Branding Creators I Administration I System SolutionTrailing Slashes on URLs: Contentious or Settled? | CSS-Methods

Web site Developer I Advertising and marketing I Social Media Advertising and marketing I Content material Creators I Branding Creators I Administration I System SolutionTrailing Slashes on URLs: Contentious or Settled? | CSS-Methods

Web site Developer I Advertising and marketing I Social Media Advertising and marketing I Content material Creators I Branding Creators I Administration I System Answer

A enjoyable deep dive from Zach. Do you might have an opinion on which you must use?

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

The primary choice has a “trailing slash.” The second doesn’t.

I’ve all the time most popular this pondering: you utilize a trailing slash if that web page has youngster pages (as in, it’s one thing of a listing web page, even when has distinctive content material of its personal). If it’s the end-of-the-line (of content material), no trailing slash.

I say that, however this very website doesn’t observe it. Weblog posts on this website are like css-tricks.com/blog-post/ with a trailing slash and for those who depart off the trailing slash, WordPress will redirect to incorporate it. That’s a part of the rationale Zach is right here. Redirects include a efficiency penalty, so it’s preferrred to have it occur as occasionally attainable.

Efficiency is one factor, however search engine optimization is one other one. For those who render the identical content material, each with and and not using a trailing slash, that’s theoretically a reproduction content material penalty and a no-no. (Though that appears bizarre to me, I’d suppose Google would sensible sufficient to not be terribly involved by this.)

The place sources resolve to looks like the most important deal to me. Right here’s Zach:

For those who’re utilizing relative useful resource URLs, the property could also be lacking on Vercel, Render, and Azure Static Net Apps (relying on which duplicated endpoint you’ve visited).

<img src="https://css-tricks.com/trailing-slashes-on-urls-contentious-or-settled/image.avif"> on /useful resource/ resolves to /useful resource/picture.avif

<img src="https://css-tricks.com/trailing-slashes-on-urls-contentious-or-settled/image.avif"> on /useful resource resolves to /picture.avif

That’s a non-trivial distinction and, to me, a motive the redirect is price it. Can’t be having a web page with damaged sources for one thing this foolish.

What complicates that is that the site-building framework may need opinions about this and a internet hosting supplier may need opinions about this. As Zach notes, there are some disagreements amongst hosts, so it’s one thing to look at for.

Me, I’d go together with the grain as a lot as I presumably may. So long as redirects are in place and I don’t must override any config, I’m cool.


Direct Hyperlink →

Supply hyperlink

Leave a Reply