Can't seem to get index.md to reliably reroute to readme.md #4335
Open
Description
Describe the bug
Tried these:
rewrites: {
':c0/readme.md': ':c0/index.md',
':c0/:c1/readme.md': ':c0/:c1/index.md',
':c0/:c1/:c2/readme.md': ':c0/:c1/:c2/index.md',
':c0/:c1/:c2/:c3/readme.md': ':c0/:c1/:c2/:c3/index.md',
':c0/:c1/:c2/:c3/:c4/readme.md': ':c0/:c1/:c2/:c3/:c4/index.md',
':c0/:c1/:c2/:c3/:c4/:c5/readme.md': ':c0/:c1/:c2/:c3/:c4/:c5/index.md',
':c0/:c1/:c2/:c3/:c4/:c5/:c6/readme.md': ':c0/:c1/:c2/:c3/:c4/:c5/:c6/index.md',
':c0/:c1/:c2/:c3/:c4/:c5/:c6/:c7/readme.md': ':c0/:c1/:c2/:c3/:c4/:c5/:c6/:c7/index.md',
':c0/:c1/:c2/:c3/:c4/:c5/:c6/:c7/:c8/readme.md': ':c0/:c1/:c2/:c3/:c4/:c5/:c6/:c7/:c8/index.md',
}
- /folder/index.html
- /folder/readme.html
- /folder/
rewrites: {
':c0/readme.html': ':c0/index.html',
':c0/:c1/readme.html': ':c0/:c1/index.html',
':c0/:c1/:c2/readme.html': ':c0/:c1/:c2/index.html',
':c0/:c1/:c2/:c3/readme.html': ':c0/:c1/:c2/:c3/index.html',
':c0/:c1/:c2/:c3/:c4/readme.html': ':c0/:c1/:c2/:c3/:c4/index.html',
':c0/:c1/:c2/:c3/:c4/:c5/readme.html': ':c0/:c1/:c2/:c3/:c4/:c5/index.html',
':c0/:c1/:c2/:c3/:c4/:c5/:c6/readme.html': ':c0/:c1/:c2/:c3/:c4/:c5/:c6/index.html',
':c0/:c1/:c2/:c3/:c4/:c5/:c6/:c7/readme.html': ':c0/:c1/:c2/:c3/:c4/:c5/:c6/:c7/index.html',
':c0/:c1/:c2/:c3/:c4/:c5/:c6/:c7/:c8/readme.html': ':c0/:c1/:c2/:c3/:c4/:c5/:c6/:c7/:c8/index.html',
},
- /folder/index.html
- /folder/readme.html
- /folder/
rewrites: {
'(.*)/readme.md': '(.*)/index.md'
}
- /folder/index.html
- /folder/readme.html
- /folder/
rewrites: {
'(.*)/readme.html': '(.*)/index.html'
}
- /folder/index.html
- /folder/readme.html
- /folder/
rewrites: {
'(.*)/readme': '(.*)/index'
}
- /folder/index.html
- /folder/readme.html
- /folder/
Some work in docs:dev, but not when built.
Reproduction
Add the rewrites to the config.mts
Create a folder named folder
, add readme.md to it, and try to go to all 3 of these URLs:
- localhost:5173/folder/
- localhost:5173/folder/index.html
- localhost:5173/folder/readme.html
Expected behavior
for /folder/index.md, /folder/readme.md, and /folder/ to lead to the same place.
System Info
╭─ cmd Lodestone main ≡ ~3 1m 44s 857ms⠀ 22.9.0 Zach@zPc-i1 3,00:55
╰─ npx envinfo --system --npmPackages vitepress --binaries --browsers
Need to install the following packages:
envinfo@7.14.0
Ok to proceed? (y) y
System:
OS: Windows 10 10.0.19044
CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
Memory: 4.64 GB / 31.93 GB
Binaries:
Node: 22.9.0 - C:\Program Files\nodejs\node.EXE
npm: 10.8.3 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0)
Internet Explorer: 11.0.19041.1202
npmPackages:
vitepress: ^1.4.2 => 1.4.2
Additional context
To me this seems like a bug but if it is not, and I'm doing it wrong, please redirect me to the correct place to get this answered/fixed.
Additionally I'm using vitepress-sidebar, which shows the Readme file and links to readme.html.
Validations
- Check if you're on the latest VitePress version.
- Follow our Code of Conduct
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.