Templates
The page template can be edited easily via the [MkPage.template][mknodes.PageTemplate] attribute. If any block gets modified then MkNodes will generate an individual template HTML file for the page during the build process.
An example:
would generate the following template override automatically:{ % extends "main.html" % }
{ % block content % }
<div class="admonition info">
<p class="admonition-title">Info</p>
<p>Some text</p>
</div>
{ % endblock % }
page.template.announce.content = mk.MkMetadataBadges(typ="classifiers")
page.template.footer.content = mk.MkProgressBar(50)
page.template.tabs.content = mk.MkCode("information = 'You can even put MkNodes here!'")
page.template.hero.content = mk.MkHeader("A header!")
PageTemplate Blocks¶
Title block ([MkPage.template.title][mknodes.pages.templateblocks.TitleBlock])¶
The title block allows to modify the title tag in HEAD
Libs block ([MkPage.template.libs][mknodes.pages.templateblocks.LibsBlock])¶
The libs block can be used to add additional JavaScript libraries.
Analytics block ([MkPage.template.analytics][mknodes.pages.templateblocks.AnalyticsBlock])¶
The analytics block can be used to set custom analytics.
Scripts block ([MkPage.template.scripts][mknodes.pages.templateblocks.ScriptsBlock])¶
The scripts block can be used to add custom JavaScripts, put at end of HTML body.
Site meta block ([MkPage.template.site_meta][mknodes.pages.templateblocks.SiteMetaBlock])¶
The site_meta block contains the site metadata. By default it gets populated by data from the MkDocs config file.
Styles block ([MkPage.template.styles][mknodes.pages.templateblocks.StylesBlock])¶
The styles block can be used to add additional CSS.
ExtraHead block ([MkPage.template.styles][mknodes.pages.templateblocks.ExtraHeadBlock])¶
The extrahead block allows to add content to the HTML head which does not suit the other categories, like redirecting to another URL.
HTML blocks¶
HTML blocks can get populated with Markdown, which will get converted to HTML during the build process.
- [MkPage.template.content_block][mknodes.pages.templateblocks.HtmlBlock]
- [MkPage.template.footer][mknodes.pages.templateblocks.HtmlBlock]
- [MkPage.template.site_nav][mknodes.pages.templateblocks.HtmlBlock]
MkDocs-Material-exclusive blocks:
- [MkPage.template.tabs][mknodes.pages.templateblocks.HtmlBlock]
- [MkPage.template.outdated][mknodes.pages.templateblocks.HtmlBlock]
- [MkPage.template.hero][mknodes.pages.templateblocks.HtmlBlock]
- [MkPage.template.announce][mknodes.pages.templateblocks.HtmlBlock]
page.template.announce.content = mk.MkMetadataBadges(typ="classifiers")
page.template.footer.content = mk.MkProgressBar(50)
page.template.tabs.content = mk.MkCode("information = 'You can even put MkNodes here!'")
page.template.hero.content = mk.MkHeader("A header!")
Page info
Code for this page
Resources
Resources(css=[],
markdown_extensions={'attr_list': {},
'md_in_html': {},
'pymdownx.emoji': {'emoji_generator': <function to_svg at 0x7fd7a6931800>,
'emoji_index': <function twemoji at 0x7fd7a69316c0>},
'pymdownx.magiclink': {'repo': 'mknodes',
'repo_url_shorthand': True,
'user': 'phil65'}},
plugins=[],
js=[],
assets=[],
packages=[])