mdBook
mdBook copied to clipboard
Internal links to README.md are broken
README.md gets translated to index.html, but internal links (except for those in SUMMARY.md) don't get translated. So they point to a non-existent README.html path. mdBook should either generate both index.html and README.html or translate internal links so that they point to index.html instead.
Ok, here's an example:
If you want to add a link to some page, you can type [Some page](some_dir/some_page.md), but if you try to link README this way, the link will be broken.
Repro steps
docker run -it --rm rust:slim bash
# cargo install mdbook
# mkdir /app
# cd /app
# mdbook init
...
# printf "[Test](./test/README.md)\n[Test 2](./test.md)" > src/SUMMARY.md
# printf "[Test](./test/README.md)" > src/test.md
# mkdir src/test
# printf "# Test" > src/test/README.md
# mdbook build
# cat book/test.html | grep README.html
<p><a href="./test/README.html">Test</a></p>
# ls book/test
index.html
duplicated issue? https://github.com/rust-lang/mdBook/issues/1268
Yea, both issues are essentially the same. I'll keep this one, but there is some more context and discussion in #1268 that is worth reading.
So what's the latest on this? I'm just seeing a circular loop of duplicate_of's and closed Issues that don't seem to go anywhere. Is there a way to resolve this currently?
@umdstu You can upvote #1921
Just in case anybody stumbles upon the same issue:
We use this one line in our ci script using find and sed (with extended regular expressions support):
find $MD_BOOK_ROOT/src/ -type f -name "*.md" ! -iname "SUMMARY.md" -exec sed -ri 's/(\[.*\])\((.*\/)?(readme\.md)(#.*)?\)/\1\(\2index\.md\4\)/gI' {} \;
Looks funky, but it just works :)
Opinion: Mapping README.md to index.html seems fine, however if that is done then I think any links to README.md also need to be handled. The options seem to be:
- Update the links
- Include a README.html in the output that is a copy of index.html or that redirects to index.html
Any update? 😥