Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal links to README.md are broken #984

Open
lily-commure opened this issue Jul 20, 2019 · 9 comments
Open

Internal links to README.md are broken #984

lily-commure opened this issue Jul 20, 2019 · 9 comments
Labels
A-Links Area: Issues with links A-Summary Area: The summary page, organization of pages.

Comments

@lily-commure
Copy link

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.

@WofWca
Copy link
Contributor

WofWca commented Jul 28, 2019

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.

@nihaals
Copy link
Contributor

nihaals commented Sep 22, 2020

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

@YushiOMOTE
Copy link

duplicated issue? #1268

@ehuss
Copy link
Contributor

ehuss commented Jul 26, 2021

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.

@umdstu
Copy link

umdstu commented Aug 29, 2022

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?

@sanmai-NL
Copy link

@umdstu You can upvote #1921

HU90m added a commit to HU90m/opentitan that referenced this issue Feb 20, 2023
We use the built-in `index` preprocessor to rename our `README.md` files
to `index.md`, but it doesn't currently fixup links:
<rust-lang/mdBook#984>.

This is a temporary preprocessor to regex replace those links until
upstream gets fixed.

Signed-off-by: Hugo McNally <[email protected]>
HU90m added a commit to HU90m/opentitan that referenced this issue Mar 1, 2023
We use the built-in `index` preprocessor to rename our `README.md` files
to `index.md`, but it doesn't currently fixup links:
<rust-lang/mdBook#984>.

This is a temporary preprocessor to regex replace those links until
upstream gets fixed.

Signed-off-by: Hugo McNally <[email protected]>
HU90m added a commit to HU90m/opentitan that referenced this issue Mar 6, 2023
We use the built-in `index` preprocessor to rename our `README.md` files
to `index.md`, but it doesn't currently fixup links:
<rust-lang/mdBook#984>.

This is a temporary preprocessor to regex replace those links until
upstream gets fixed.

Signed-off-by: Hugo McNally <[email protected]>
HU90m added a commit to HU90m/opentitan that referenced this issue Mar 6, 2023
We use the built-in `index` preprocessor to rename our `README.md` files
to `index.md`, but it doesn't currently fixup links:
<rust-lang/mdBook#984>.

This is a temporary preprocessor to regex replace those links until
upstream gets fixed.

Signed-off-by: Hugo McNally <[email protected]>
GregAC pushed a commit to lowRISC/opentitan that referenced this issue Mar 7, 2023
We use the built-in `index` preprocessor to rename our `README.md` files
to `index.md`, but it doesn't currently fixup links:
<rust-lang/mdBook#984>.

This is a temporary preprocessor to regex replace those links until
upstream gets fixed.

Signed-off-by: Hugo McNally <[email protected]>
@SeWieland
Copy link

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 :)

@bitdivine
Copy link

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

@carlocorradini
Copy link

Any update? 😥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Links Area: Issues with links A-Summary Area: The summary page, organization of pages.
Projects
None yet
Development

No branches or pull requests

10 participants