Pages with numeric prefixes get their URLs mangled
Describe the bug
(sorry, me again!)
A page with an initial number (e.g. 1-number-test.md) gets rendered as number-test/index.html - that is to say, when the filename begins with a number, it's considered a prefix and stripped from the resulting URL.
This may be intended behaviour (there seems to be code to actively strip prefixes), but it would be nice if it was configurable (or at least documented).
To reproduce
- Create a page with a numeric prefix - e.g.
pages/1-number-test.md - Build the site -
cecil.phar build - Output appears in
_site/number-test/index.html
Expected behavior
I would prefer it to be:
- Output appears in
_site/1-number-test/index.html
Version
7.43.0
Operating System
Ubuntu 20.04
Relevant log output
No response
To follow up on this; I've managed to spot that this behaviour is sort of explained in the docs (confusingly, under Content/Variables), so I guess this is more of a feature request - to add something in config.yml to allow me to retain prefixes in the resulting titles / page ID.
FWIW I do have a workaround - renaming the page to 1 number-test.md (i.e. with a space instead of a hyphen) resolves the problem, so although it would be nice to have a configuration to control prefix behaviour better, it might just be something that needs to be better documented (perhaps under 'File organisation' instead of buried in Variables?)
Hello @ahnlak, thanks for your report.
I thought about the problem and asked myself what would be the most practical and effective.
2 options identified for the moment:
- Add an option in the configuration to be able to disable this behavior. Disadvantages: many impacts on existing code, should this option be global? per page? by section? by page type? other ?
- Change the prefix separator: today it is possible to use "-" or "_". Maybe by removing the "-" and keeping only the "_" it would be enough to distinguish the page title from its prefix?
As you say, it may be tricky to address the problem without impacting existing usage; it's easy enough to work with once you know it's there (I just switched to using spaces after any numeric-prefixed filenames), so perhaps it just needs to be more obviously documented - perhaps under file based routing, where the mapping between filename and URL is explained.