Search code examples
markdownreadmemkdocs

Mkdocs eliminate copy paste in files


Can I somehow include a file into a file in mkdocs? I do not want to copy paste the same sections again and again. Thanks


Solution

  • Including one document in another is not a Markdown feature, and currently MkDocs only does Markdown processing on Markdown documents. Therefore, at this time there is no way to do this with MkDocs.

    Interestingly, it does not even appear that anyone has made such a feature request. There is the pending feature to make various variables available to be displayed within a Markdown page (see issue #304), but no mention is made there of including other documents. That said, depending on the solution chosen, its possible that if/when the issue is addressed it will also provide for the ability to include other pages.

    Either way, if/when a Plugin API is added (see issue #206) you should be able to do any prepossessing of your own which would include running the Markdown text through a template system which support "including" pages before the Markdown is parsed. In fact, I expect that if you were to make a feature request, the answer would be to punt it to a Plugin.