I have a mkdocs project that resembles the following:
project
├─mkdocs.yml
├─docs
│ ├─home.md
│ ├─chapter1.md
│
├─static
├─file.ext
├─image.png
I am trying to find a way to "attach" file1.ext to the build, for instance as a link in chapter1.md.
Any suggestions how to achieve that? Detail: I want the file to be downloadable on click.
In
mkdocs, to get the file to be downloadable on click usingmarkdown, first you need to add this to yourmkdocs.ymlfile :and then in your
chapter1.mdyou can adddownloadattribute to your link ... like so :Heck you can even name the downloaded file:
Explanation
MkDocs converts Markdown to HTML using Python-Markdown which offers a flexible extension mechanism, which makes it possible to change and/or extend the behavior of the parser without having to edit the actual source files.
The
markdown_extensionsinmkdocs.ymlsetting specifies the Python-Markdown extensions for MkDocs. addingattr_listentry point enables the Python-Markdown attribute lists extension, which adds support for HTML-style attributes using curly brackets{}and a CSS-like syntax.example:
let's say we want to open a link in new tab, we can achieve this like so :