Skip to content

Don't treat subdir/index.md and subdir/subdir.md the same #3919

@darthmall

Description

@darthmall

Is your feature request related to a problem? Please describe.

The behavior for generating permalinks when the file name is the same as the directory name can cause some unexpected and surprising problems. If a person wants to use a structure based on dates and directories such as year/month/day.md, then one day a month (the day when the date matches the month), the URLs will not be correct. A blog post published for 8 August 2025 will have the URL /2025/08/ instead of /2025/08/08/ as expected.

Describe the solution you'd like

Instead of mapping subdir/subdir.md to subdir/index.html, the filename should be preserved in the permalink, as it is in all other cases. subdir/subdir.md should, by default, have the permalink subdir/subdir/index.html.

Describe alternatives you've considered

It is possible to override the permalink with a directory data file to create this behavior:

export default {
  permalink: function ({ path }) {
    if (path.filePathStem.endsWith("index")) return `${page.filePathStem}.html`;
    return `${page.filePathStem}/index.html`;
  }
}

It feels weird to resort to overriding the permalink for all the files in a directory when, for example, only 1 file in about 30 will have an issue. Especially given that if you want a template that writes out to subdir/index.html you already have two means of doing so:

  1. Create a template called subdir/index.md (the most obvious solution)
  2. Create a template called whatever you want, and set the permalink for just that template to write to subdir/index.html

Additional context

I ran into this problem helping a friend who had structured their blog thus: /blog/<year>/<month>/<day>.md. And she had trouble on 8 August because her post wasn’t showing up where she expected. I was caught by surprise (as was she), because I did not expect Eleventy to collapse the file name out of the URL just because it matched the directory name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeThis will have to be included with a major version as it breaks backwards compatibility.enhancement

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions