Exclamation Mark in URL in Front Matter

If you want a specific piece of content to have an exact URL, you can specify this in the front matter under the url key.

I want a URL with an exclamation mark (using the “!” character, not encoded). Defining a URL with an “!” in the front matter fails to display the file when running locally (returns 404), which is definitely a bug. My question is: will this still generate correctly? My build isn’t compiling atm so I am wondering if this is only a local server bug… Thanks.

I don’t think that’s possible. ! is not part of the official URL scheme and will always be encoded by a browser. Now you might come up with “hey but AngularJS uses it”. They do. But they use it after the hashtag # which denotes an object on the page you loaded. That will not be part of your “URL”. It’s additional info. Don’t even start with it.

It’s not a bug. It’s one of the rules of the internets.

According to RFC 1738, an exclamation mark is a valid character:

Thus, only alphanumerics, the special characters “$-_.+!*’(),”, and reserved characters used for their reserved purposes may be used unencoded within a URL.

Example valid URLs:

This is supported by all of your browsers and most CMSs because it is valid, at least according to the specs.

Right after that it says:

On the other hand, characters that are not required to be encoded
(including alphanumerics) may be encoded within the scheme-specific
part of a URL, as long as they are not being used for a reserved

There is no reserved purpose for ! in URLs

Your first sample is redirected. Your second sample ends up on a 404 page. Can you please refer me to an URL that has ! in it and KEEPS it after loading?

The further RFC 1738 talks about “gopher item”. I don’t even want to step into researching what that means… but it sounds a lot like extra information after the original path:

3.4.6 Gopher+ item attribute collections
To refer to the Gopher+ attributes of an item, the Gopher URL’s
Gopher+ string consists of “!” or “". "!" refers to the all of a Gopher+ item's attributes. "” refers to all the item attributes for
all items in a Gopher directory.

Just for posterities sake, here the link to what we are talking about: https://tools.ietf.org/rfc/rfc1738.txt

Sorry, forgot to follow up. Here is another example:

Neither browsers nor servers have problems with exclamation marks, as it is allowed by the RFC. In the portion you posted, the RFC is simply saying that any non-reserved characters (even alphanumerics) can be encoded… but browsers, servers, etc. must also be able to deal with them unencoded because the aforementioned characters (alphanumerics, “$-_.+!*’(),”, and reserved characters) are all valid parts of a URL, unencoded.

This is indeed a bug in Hugo but I realized I don’t need this fixed as I can easily add the ! in post-processing (which I need to do anyway for a different reason).