Proposal: Config option to keep dates in slugs

See this link for a copy of this post with more links (because Discourse only lets new users have 1 or 2 links, and I want to use links to provide more details)

Pages like content/2022-07-21_topic/index.md or content/2022-07-21_topic.md have the date removed, so zola will choose the slug: topic.

For some blogs, the date is a key part of the page title, and this behavior leads to entries with the same slug.

I would like to have a config option to disable this behavior. Others have asked for this previously.

With this option, pages like content/2022-07-21_topic/index.md or content/2022-07-21_topic.md would keep their date, so zola would choose the slug: 2022-07-21-topic.

The main code to change for this is components/library/src/content/page.rs.

The configuration (components/config/src/config/mod.rs) will also need changes to pass in the option.

  • Questions: What should the config option be called?
    • slug_keep_dates (default false)
    • slug_strip_dates (default true)

Finally, the user documentation needs to be updated with this change.

I intend to work on this, and send a pull request. Any feedback on this plan is welcome!

I sent a PR with some refactoring to prepare: Cleanup code to generate page slug. by DerSaidin · Pull Request #1936 · getzola/zola · GitHub

Bump :slight_smile:

I think ideally it would be on the section but that does mean passing the section data to the page when loading it, which isn’t ideal…