Are there global variables or similar feature in mdbook

If i have a link i am using in multiple .md files in an mdbook, is there a way to store that link in a global variable and use it in several places in the book, so that if i need to change that link, i only change it in one place.

mdBook supports preprocessors and has a built-in one for including files. You could keep your links in a separate file, i.e.:


and include it in the markdown files you need them:

[Rust][rust-lang] is a cool programming language and [mdBook][mdbook]
is a great tool for writing documentation!

1 Like

It's not working for me, also the .md files are all in the same directory. i think something maybe missing.

Sorry, I messed up the syntax in my example. Reference-links are in the form [Rust][rust-lang], not [Rust](rust-lang). Fixed the example. As to being in the src directory, that shouldn't matter if you don't add it to as a chapter.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.