Hugo support for URLs without a trailing slash?

Sorry for making too bold statements based on assumptions rather than data. I shall try to make up for that.

1)
I surrender, bep have much better data to judge this than me.

2)
Here is what I got:

  • Wordpress is flexible and allows you to set a permalink structure with or without trailing slash. So for some Wordpress migrations, it will be an issue, for others it won’t
  • Drupal does not use trailing slash [#]
  • Joomla does not have trailing slash either [#]
  • ExpressionEngine, it seems, went from trailing slash in EE1 to no trailing slash in EE2 [#]

This is not enough data to make any claims of “most CMS systems”. But it seems that “no trailing slash” is common in CMS’es, and thus point (2) seems valid

3)

@bep, You are right about the semantics, as understood as semantics of URL resolution on most, if not all web servers. I was not thinking about those semantics, but rather the semantics of URLs generally, decoupled from technicalities on web servers.

RFC 1630 has the following to say about using slash:

If the URN has a hierarchical nature, then the slash delimiter shall be used in the URI encoding; If the URN has a hierarchical nature, the most significant part shall be encoded on the left in the URI encoding;

The “semantics” of using a slash is thus according to this definition to delimit hierarchical content. Using these semantics stricly, it does not make sense to add a trailing slash.

However, a trailing slash has gotten a special meaning by usage. It has been used for directories. I guess we can call this meaning semantics too, even though it may only exist as a convention, and not in any specification. In this way, it makes semantical sense to use a trailing slash for indexes, such as a listing of all tags at a location “/tags/”. But not for individual posts.

4)
Perhaps a more compelling reason than the ones I came up with originally is that of flexibility - The freedom to have your URL’s as you want them.

@bep, you say support for URLs without a trailing slash is do-able now. Do you have a solution in mind which affects all urls, or one that can be customized? A general option which can be overridden would be nice and flexible.

Cheers,
Bjørn

1 Like