In mkdocs
, to get the file to be downloadable on click using markdown
, first you need to add this to your mkdocs.yml
file :
markdown_extensions:
- attr_list
and then in your chapter1.md
you can add download
attribute to your link ... like so :
[file.ext](../static/file.ext){:download}
Heck you can even specifies the new filename for the downloaded file:
[file.ext](../static/file.ext){:download="awesome-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_extensions
in mkdocs.yml
setting specifies the Python-Markdown extensions for MkDocs.
adding attr_list
entry 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 :
[Google](https://www.google.com){:target="_blank"}