rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.84k stars 1.62k forks source link

Support different URL formats #2424

Closed srid closed 1 month ago

srid commented 1 month ago

Problem

Presently, mdBook is hardcoded to convert foo/bar.md to foo/bar.html, with all links to it unconditionally be foo/bar.html. This is even the case for foo/index.html URL (where the index.html part is not necessary; see #1251).

Proposed Solution

In addition to the current behaviour, allow a way to configure in book.toml different URL formats. Specifically, support these two:

  1. Directory URLs: Have foo/bar.md generate foo/bar/index.html instead, and use foo/bar/ as the URL link to it.
  2. Slug URLs: Have foo/bar.md generate foo/bar.html, as usual, but link to it as foo/bar - i.e., without the .html suffix.
    • This is especially useful to have "pretty URLs" on Github Pages static sites. Instead of https://rust-lang.github.io/mdBook/cli/serve.html, users would see https://rust-lang.github.io/mdBook/cli/serve

Notes

No response

ehuss commented 1 month ago

Thanks for the suggestion! I believe this is mostly a duplicate of #1563, so closing in favor of that.