docusaurus: Autogenerated sidebar item from subfolder don't respect `index.md` at the subfolder root
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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
It seems that autogenerated items for subfolders containing an index.md file don’t show up as sections.
For instance, on the sample website from the the 5m tutorial, I would have expected this:
const sidebars = {
tutorialSidebar: [
"intro",
{type: 'autogenerated', dirName: 'tutorial-basics'},
{type: 'autogenerated', dirName: 'tutorial-extras'},
],
}
to create two sections in the sidebar because they both contain a _category_.json file but everything is actually flattened at the root. Replacing both _category_.json with an index.md leads to the same results.
Is this expected?
Reproducible demo
Steps to reproduce
npm init docusaurus@latest my-website classic- Update
sidebars.jsfrom:
tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
to
const sidebars = {
tutorialSidebar: [
"intro",
{type: 'autogenerated', dirName: 'tutorial-basics'},
{type: 'autogenerated', dirName: 'tutorial-extras'},
],
}
Expected behavior
I would expect two sections to appear in the sidebar since both subfolders contain a _category_.json.
Actual behavior
The content of the two sections is actually flattened at the root.
NOTE: replacing the _category_.json files with an index.md files leads to the same results.
Your environment
- Docusaurus version used: 2.4.1
Self-service
- I’d be willing to fix this bug myself.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 20
I don’t think there’s anything wrong with Docusaurus’ behavior—I agree with @slorber that we can try #5689 first, although I think
autogenerated-categorywill still be very intuitive and convenient, but that would be another feature request 😃Neither the presence of
index.mdnor_category_.jsoncan affect whether a folder becomes a category or a sidebar slice—that would be a huge behavior inconsistency. These files are picked up when and only when the folder is actually destined to become a category.