Closed Xeverous closed 3 years ago
Did you try using FILE_METADATA_REGEXP
? I think it should be possible to set slugs to the filename with it, with eg. r".*/(?P<slug>)\..*"
Interesting feature, could be really useful for me as I already focus heavily on file names in my repository (they dictate what some tools do). But it still doesn't change the fact that according to the documentation, slugs are mandatory. Would they be not mandatory if I use this feature right now (no Nikola update)?
I noticed Nikola works even if I don't write slugs (also without FILE_METADATA_REGEXP
), but then I'm relying on implementation details which can change any time. I just want to be sure I don't base my work on some accidental implementation detail.
The docs seem a bit overzealous, I just fixed them.
Great. Basically a feature for no effort!
Requested Feature: make
slug
metadata field optional. Default it to source file name (without extension).Related Area: metadata
Do you want to contribute this yourself as a pull request? (don’t worry about it if you don’t want to/can’t — someone else can take care of it)
Does this feature affect backwards compatibility? If yes, in what way?
No, because according to documentation currently
slug
metadata field is required.Rationale and full description: (why should it be added to Nikola?)
I have noticed that all my pages use a slug equivalent to their filename (without extension). I have even written extra code that checks it for correctness.
AFAIK the slug is only used for link generation. Web servers by default serve files (and directories) under links which are 1:1 matched with the path to the resource, so using slug equivalent to the file name only extends this already established default.
Problematic file names (documentation recommends only
a-z0-9-_
) could be solved in 2 ways:` (space) becomes
%20`)