Skip to content

Index Generated Category Link in different folders overriding each other #11225

Closed as duplicate

Description

@Funeoz

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

There is a bug in the documentation structure where the link for an category in one folder is replacing the link for a category in another folder, despite them being in completely different locations. This happens when the category label is the same.

This results in incorrect category attributes displayed in the generated index pages.

Reproducible demo

https://codesandbox.io/p/devbox/lucid-northcutt-8lp9z5

Steps to reproduce

  1. Ensure that the sidebar is autogenerated in sidebars.js from the root docs/ folder

  2. Create two folders Alpha and Beta in the docs/ folder. In each folder, create a test folder and a sample test.md file without content inside. We have the following configuration :

docs/
  alpha/
    test/
      test.md
  beta/
    test/
      test.md
  1. Create a category file _category_.json in docs/alpha with the following content :
{
  "label": "Alpha",
  "link": {
    "type": "generated-index"
  }
}
  1. Create a category file _category_.json in docs/beta with the following content :
{
  "label": "Beta",
  "link": {
    "type": "generated-index"
  }
}
  1. Create a category file _category_.json in docs/alpha/test with the following content:
{
    "label": "CategoryLabelTest",
    "link": {
      "type": "generated-index",
      "title": "test category in Alpha",
      "description" : "Test description in Alpha"
    }
}
  1. Create a category file _category_.json in docs/beta/test with the following content:
{
    "label": "CategoryLabelTest",
    "link": {
      "type": "generated-index",
      "title": "test category in Beta",
      "description" : "Test description in Beta"
    }
}

Final docs/ directory structure is the following :

docs/
  alpha/
    _category_.json
    test/
      test.md
      _category_.json
  beta/
    _category_.json
    test/
      test.md
      _category_.json

Expected behavior

Each link in different categories should keep their own distinct attributes.

Actual behavior

Based on the previous example, the link title in docs/beta/test/_category_.json is overriding the title in docs/alpha/test/_category_.json. Same for the description.

Image

Moreover, URL becomes docs/category/categorylabeltest and docs/category/categorylabeltest-1 instead of expected respectively docs/category/alpha/categorylabeltest and docs/category/beta/categorylabeltest

Image

Image

Your environment

  • Docusaurus version used : 3.8.0
  • Environment name and version : Firefox 139.0.1, Node 22.14.0
  • Operating system and version : Windows 11 24H2

Self-service

  • I'd be willing to fix this bug myself.

Activity

  1. added
    bug
    status: needs triage
    on Jun 1, 2025
  2. slorber commented on Jun 2, 2025

    @slorber
    Collaborator

    Yes this looks like a bug, probably a naming collision in JSON modules we emit. I wonder if this is related to #11136 or a different one.


    Moreover, URL becomes docs/category/categorylabeltest and docs/category/categorylabeltest-1 instead of expected respectively docs/category/alpha/categorylabeltest and docs/category/beta/categorylabeltest

    This behavior is expected.

    Category index URLs follow the /category/${slug(category.label)} pattern by default, and do not include any parent category label.

    You can override/customize it with the link.slug attribute:
    https://docusaurus.io/docs/next/sidebar/items#generated-index-page

  3. removed
    status: needs triage
    on Jun 2, 2025
  4. slorber commented on Jun 4, 2025

    @slorber
    Collaborator

    It's due to our i18n system creating duplicate translation keys.

    I'll see how to fix it, or at least ensure it doesn't affect sites that do not use i18n by default.

    Duplicate of #10913

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions