Skip to content

feat: URLs with no index.html suffix #3047

Open
jhult wants to merge 12 commits intorust-lang:masterfrom
jhult:feat/no-html-ext
Open

feat: URLs with no index.html suffix #3047
jhult wants to merge 12 commits intorust-lang:masterfrom
jhult:feat/no-html-ext

Conversation

@jhult
Copy link
Copy Markdown
Contributor

@jhult jhult commented Mar 8, 2026

Fixes #1251

[output.html]
no-html-extension=true
**no-html-extension:** When set to `true`, generates clean URLs without `.html` extensions. All pages are written to directory-based paths (e.g., `chapter/index.html` instead of `chapter.html`).

Special pages are placed in `_print/`, `_toc/`, and `_404/` directories.

All internal links use trailing-slash format (`chapter/` instead of `chapter.html`).

Works with all major static hosting providers (GitHub Pages, Netlify, Cloudflare Pages) and the built-in `mdbook serve` command.

**Note:** Chapter paths starting with `_print`, `_toc`, or `_404` will cause a build error.

Defaults to `false`.

Vaguely related PRs: #2570, #2993, #3028, #3034, #3038

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Mar 8, 2026
@bens-schreiber
Copy link
Copy Markdown

Certainly fixes my issue #3028 . Would love to get this in.

@jhult
Copy link
Copy Markdown
Contributor Author

jhult commented Mar 9, 2026

@ehuss or @Dylan-DPC, I think many people would appreciate this being merged. I'd love any feedback you have to share.

@jhult jhult force-pushed the feat/no-html-ext branch from 3052bb5 to b2230d7 Compare March 16, 2026 19:43
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 16, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

jhult added 9 commits March 21, 2026 00:14
When clean URLs are enabled, pages are output to subdirectories (e.g., `foo/bar/index.html`). In-content relative links like `[Link](other.md)` were being converted to `other/` without accounting for the current page's subdirectory location.

The fix modifies `fix_link` to:
1. Take the source chapter path as a parameter
2. Calculate `path_to_root` using `clean_url_path_to_root`
3. Prepend `path_to_root` to the fixed link

This ensures in-content links work correctly from any page depth.
-  add tests for ResourceHelper clean URL paths
The preprocessor now handles {{#if}}...{{else}}...{{/if}} blocks by keeping only the first branch and stripping trailing whitespace. Also adds required meta object for ESLint 10 compatibility.
@jhult jhult force-pushed the feat/no-html-ext branch from b2230d7 to 0c123af Compare March 22, 2026 21:47
@CattoYT
Copy link
Copy Markdown

CattoYT commented Apr 4, 2026

Just had to hop into the discussion and say that this fixed my issue with cloudflare pages

Before: https://ad2d70e6.csbook-a6u.pages.dev/
After: https://215b27f3.csbook-a6u.pages.dev/

Thanks for your work <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove index.html suffix

4 participants