You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prevent capitalisation of directory names in menu #2086
I've noticed that when nav is not specified and mkdocs generates the navigation for me, it removes underscores (_) and capitalises the first letter. Is there a possibility to prevent this behaviour to happen:
This is what the directory structure looks like:
Reacted by Zachary Gramana, Neil Farrington, Luke Stagner, Hunter Wittenborn, AR Baart, gledos Lia green, chirag-swiggy, Warren Weckesser, Vytautas Strimaitis and 4volodin
@waylan that's not possible for me as the markdown files are auto-generated using a Python script, and hence I don't know how many pages I'm going to have.
I need mkdocs to pick up everything that is generated (which it's doing) but I just don't want mkdocs to change the naming conventions I use (i.e., lower case and non-caps).
Can a flag be added to mkdocs.yml to preserve my naming convention?
Reacted by Zachary Gramana, Jean Pimentel, Steve Jamison, Misha Behersky, Yihang Wang, Hunter Wittenborn, Chris Austin, AR Baart, gledos Lia green, wwx and 12 more
defdirname_to_title(dirname):
""" Return a page tile obtained from a directory name. """title=dirnametitle=title.replace('-', ' ').replace('_', ' ')
# Capitalize if the dirname was all lowercase, otherwise leave it as-is.iftitle.lower() ==title:
title=title.capitalize()
returntitle
so it only modifies the paths when a variable in the config file is set to true?
We try to keep the number of config settings to a minimum. In fact, any recent changes to the config settings have been to remove settings, not add them. I would suggest exploring using a plugin to accomplish what you want.
The current behavior violates the Principle of Least Astonishment, as navigation menu options in the vast majority of English sites (at least) are in proper case instead of sentence case. One expects proper case to be the default behavior if it cannot be configured.
To turn it around, if there is a strong use case for sentence case, perhaps let those people then implement a plugin.
Reacted by Hugo, AR Baart, geogboe, Mitchell Cooper, Dane Hillard and EDIflyer
I just ran into this issue. I would also prefer it to not capitalize and remove the underscores from the files/directories. I have a script that creates a markdown file from each source file and the capitalization and lack of underscores makes things look awkward
Reacted by Leandro Lucarella, Christopher Barber and Johan Mynhardt
Similar to #1289, see comment #1289 (comment). Additionally, it's partially solved by the awesome pages plugin. For the reasons mentioned here and in the linked comment, we'll close as out of scope for now. Feel free to comment further or ask to re--open if you'd like to work on that.
Activity
waylan commentedon Apr 30, 2020
The only way to control the formatting of section names in the nav is to define them in the config.
mlevit commentedon Apr 30, 2020
@waylan that's not possible for me as the markdown files are auto-generated using a Python script, and hence I don't know how many pages I'm going to have.
I need mkdocs to pick up everything that is generated (which it's doing) but I just don't want mkdocs to change the naming conventions I use (i.e., lower case and non-caps).
Can a flag be added to
mkdocs.ymlto preserve my naming convention?waylan commentedon Apr 30, 2020
No, this is not supported.
mlevit commentedon May 1, 2020
@waylan do you think we could tweak
so it only modifies the paths when a variable in the config file is set to true?
waylan commentedon May 1, 2020
We try to keep the number of config settings to a minimum. In fact, any recent changes to the config settings have been to remove settings, not add them. I would suggest exploring using a plugin to accomplish what you want.
zgramana commentedon May 15, 2020
The current behavior violates the Principle of Least Astonishment, as navigation menu options in the vast majority of English sites (at least) are in proper case instead of sentence case. One expects proper case to be the default behavior if it cannot be configured.
To turn it around, if there is a strong use case for sentence case, perhaps let those people then implement a plugin.
lstagner commentedon Feb 1, 2021
I just ran into this issue. I would also prefer it to not capitalize and remove the underscores from the files/directories. I have a script that creates a markdown file from each source file and the capitalization and lack of underscores makes things look awkward
JackPott commentedon Oct 27, 2021
Agree its weird that the title from the front matter doesn't let you override the default casing.
amanbolat commentedon Apr 16, 2022
I had the same problem, so I found a plugin that solves the problem.
lukasgeiter/mkdocs-awesome-pages-plugin
After installing the plugin I added the
.pagesfile inside thedocsfolder with content:The result:
analog-cbarber commentedon Sep 20, 2023
The awesome pages plugin does solve this problem but only if the pages have a top-level title:
# this-works## this-does-notpawamoy commentedon Apr 17, 2024
Similar to #1289, see comment #1289 (comment). Additionally, it's partially solved by the awesome pages plugin. For the reasons mentioned here and in the linked comment, we'll close as out of scope for now. Feel free to comment further or ask to re--open if you'd like to work on that.