Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unwanted folder index behavior #7561

Copy link
Copy link
@FlagHunter01

Description

@FlagHunter01
Issue body actions

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.

2024-09-24_15h28_56

Witnessed behavior

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

2024-09-24_15h30_37

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    change requestIssue requests a new feature or improvementIssue requests a new feature or improvementupstreamIssue must be taken upstreamIssue must be taken upstream

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.