Search code examples
templatesjinja2markdownmkdocs

MkDocs - Have a file use a specific template


I’m probably not understanding something fundamental to Jinja and/or MkDocs but hopefully someone can point me in the right direction. I’m building a static website and using MkDocs. I need to have a landing page, some documentation pages and some product pages. Each of these will use different templates that extend main.html in different ways.

What I don’t understand is how to ensure that when building my pages, MkDocs knows which of my templates, say landing.html, product.html or docs.html template to use for a given markdown file, say landing.md, product1.md, product2.md, product3.md And doc1.md, doc2.md and doc3.md


Solution

  • The answer is to use the template key which is documented at https://www.mkdocs.org/user-guide/writing-your-docs/#meta-data