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).
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.
WordPress will redirect to whatever version you have set in your Permalink Settings. If you don’t include a trailing slash (
/%postname), WordPress will do a 301 redirect from
/test, and vice versa if you do.
Although I suppose no redirect, and inclusion of the
<link rel="canonical" href="/test">would be the most performant and not incur SEO penalty (from respectful search engines).
As I understand it, both addresses actually are incomplete.
site.com/page.php(or .html) and the
If you leave away the file extension or even the document name you maybe should at least get the slash right.
Nahhhh. You can link to a file if you want to but it’s not required and extensions are just for you and tools, browsers and the internet don’t care.
I think the trailing slash should be considered bad practice, if you look at it from the URI perspective. Adding a path separator with a empty path segment adds a lot of ambiguity.
/character indicates “sub”-something. It’d be like a breadcrumb design with an arrow at the end.
Technically speaking, there’s no extra complexity but, unless it’s the root URL, URLs with trailing slash and URLs without are not the same at all.
You must ensure you use the same URL scheme everywhere, so choose one and stick with it. Otherwise, your SEO might be impacted.
You should be very careful when migrating from one system to another if your original URL scheme has no trailing slashes. You should apply 301 redirect to prevent bad events.
Also, make sure you use canonical tags with the same scheme!
Google analytics reports the two schemes as two different URLs.
Semantically speaking, with a trailing slash you say that your URL is a directory. It makes sense with frameworks such as Hugo, as the frameworks generates numerous folders with an
You can enable
uglyURLs = trueand redirect all “*.html” ugly URLS to the correct paths (without trailing slashes or
.html) but that’s not the most convenient configuration.