-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Context
No response
Bug description
Example setting
Here is the nav for the illustrations:
nav:
- Home:
- Homepage: index.md
- Ships:
- Sailships: ships/sails/index.md
- Steam ships: ships/coal/index.md
- Trains:
- trains/index.md
- Steam trains: trains/coal/index.md
- Diesel trains: trains/diesel/index.md
Problem description
Expected behavior
When navigation.indexes
is active, I expect MkDocs to create a section index page when a nameless index.md page is placed inside in the nav
as described in the Section index pages article, and NOT create it otherwise.

Witnessed behavior
If a file path ends with index.md
, this file is elected as a section index regardless of its name.

Interpretation
This issue is due to the fact that my files are named "index". I understand that I could rename them to something else and they won't be interpreted as section indexes.
However, I am doing a perpetually growing doc and each topic that is single file will probably need multiple files in the future, so I want to be able to create a folder with a single index file per topic.
This mechanic might stem from MkDocs directly and might not be related to Material:
When a directory is requested, by default, most web servers will return an index file (usually named index.html) contained within that directory if one exists. For that reason, the homepage in all of the examples above has been named index.md, which MkDocs will render to index.html when building the site.
Many repository hosting sites provide special treatment for README files by displaying the contents of the README file when browsing the contents of a directory. Therefore, MkDocs will allow you to name your index pages as README.md instead of index.md. In that way, when users are browsing your source code, the repository host can display the index page of that directory as it is a README file. However, when MkDocs renders your site, the file will be renamed to index.html so that the server will serve it as a proper index file.
If both an index.md file and a README.md file are found in the same directory, then the index.md file is used and the README.md file is ignored.
MkDocs, writing your docs page
Warning
When doing tests, please create all pages that are reported in your nav. If not, this behavior is unpredicteable.
Related links
Reproduction
9.5.36-unwanted-index-behavior.zip
Steps to reproduce
Compare the rendering of the "ships" and the "trains" folder. Ships doesn't follow the Section index pages and should not have a section index, and "trains" should.
Browser
No response
Before submitting
- I have read and followed the bug reporting guidelines.
- I have attached links to the documentation, and possibly related issues and discussions.
- I assure that I have removed all customizations before submitting this bug report.
- I have attached a .zip file with a minimal reproduction using the built-in info plugin.