Skip to content

Add --backend argument for mdbook build command to build the specific backend #2648

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

Open
hwhsu1231 opened this issue Apr 7, 2025 · 0 comments
Labels
C-enhancement Category: Enhancement or feature request

Comments

@hwhsu1231
Copy link

Problem

According to the documentation in mdBook:

If there is more than one backend, then each backend is placed in a separate directory underneath book. For example, the above would have directories book/html and book/wordcount.

Taking the rustc-dev-guide as an example. Since it specifies both html and linkcheck backends in book.toml, running the mdbook build command generates a directory structure like this:

book/
    html/
    linkcheck/

However, I don't want this behavior. I want to generate only the HTML output directly in the book/ directory (without subdirectories like book/html/), even when multiple backends are specified in book.toml.

Proposed Solution

Provide --backend <backend> argument for mdbook build command:

  • The default value of --backend is all, which will use all backends specified in book.toml.
  • If a specific backend is provided (e.g., --backend html), only that backend will generate output.

For example:

mdbook build --backend html --dest-dir ./book

The above command will generate .html documents directly to ./book directory even if there are multiple backends specified in book.toml. The directory structure should be like this:

book/
    zzz.html
    yyy.html
    xxx.html

Notes

Let's take a look at Sphinx, which provides two arguments for specifying builders (-M and -b):

  • -M <buildername>: Outputs files in <outputdir>/<buildername> directory.
  • -b <buildername>: Outputs files directly in <outputdir> directory.

What I want is equivalent to the -b behavior—generating files directly in <outputdir> without subdirectories.

@hwhsu1231 hwhsu1231 added the C-enhancement Category: Enhancement or feature request label Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

1 participant