Cecil icon indicating copy to clipboard operation
Cecil copied to clipboard

Pages with numeric prefixes get their URLs mangled

Open ahnlak opened this issue 2 years ago • 4 comments

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

  1. Create a page with a numeric prefix - e.g. pages/1-number-test.md
  2. Build the site - cecil.phar build
  3. Output appears in _site/number-test/index.html

Expected behavior

I would prefer it to be:

  1. Output appears in _site/1-number-test/index.html

Version

7.43.0

Operating System

Ubuntu 20.04

Relevant log output

No response

ahnlak avatar Jul 06 '23 09:07 ahnlak

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.

ahnlak avatar Jul 14 '23 13:07 ahnlak

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?)

ahnlak avatar Jul 14 '23 13:07 ahnlak

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:

  1. 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 ?
  2. 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?

ArnaudLigny avatar Sep 18 '23 11:09 ArnaudLigny

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.

ahnlak avatar Sep 18 '23 13:09 ahnlak