As expected, when the site is built, the ! and ? characters are stripped from the url, hence from the directories containing the respective index.html. That leads me to have 2 different posts with the same url/path.
However, I manually edited the public generated directory to have two directories named test! and test? and pushed the whole site to Github (link).
Github seems to have no problem in working with those paths having special characters (link)
After read a lot of similar questions I am confident that this is the expected behavior, however I wonder if that behavior can be disabled or is there any other workaround instead of manually rename generated files.
What I’d like to know is if there is any way to tell Hugo that I know what I’m doing and I want to encode those special characters instead to indiscriminately strip them.
For me it would be OK if Hugo encode test! as test%21 and test? as test%3F (which are valid parts of URLs) and browse the pages using /test%21/ and test%3F/ respectively.
which seems to create the directories as I desired. However, as Hugo maps URLs 1:1 over paths this is even worst: while the .Permalink is /test%21/ the document is accesible only through /test%2521/ (Notice that now the % is encoded).
So the only solution seems to have directories named /test!/ but even the filesystems have their own set of reserved characters.