List of Macros

{{content}}

Expands to the HTMLified content of the current page. Macros in the HTML content are expanded.

You should only use {{content}} in template files. Using it in content files will result in infinite recursion.

{{title}}

Expands to the text content of the first <h1> element on the page, or the filename if there is no <h1>.

{{title}} is mostly useful in the <title> element of template files. Note that mdsite reuses the {{title}} logic internally to generate the titles of navigation links, e.g. in {{toc}} and {{breadcrumb}}.

{{toc}}

Generates a table of contents. With no arguments, it generates a TOC for the current page's directory and its subdirectories.

You can optionally specify the directory whose table of contents you want to generate. This must be an absolute path, which mdsite will interpret, as always, as relative to the source root.

For example, to generate the TOC for the whole site, you could use {{toc /}}.

{{next}}

Generates a link to the next page on the site. The order of pages is determined by order.txt files.

{{prev}}

Generates a link to the previous page on the site. The order of pages is determined by order.txt files.

{{up}}

Generates a link to the parent of the current page.

If the current page is a leaf (e.g. foo.md), its parent is the index page in the same directory.

If the current page is an index (index.md or index.html), its parent is the index page one level up in the directory tree.

{{home}}

Generates a link to the root index page, /index.html.

{{breadcrumb}}

Generates a breadcrumb that links to all ancestors of the current page.

By default, the breadcrumb is wrapped in a <nav> element like the following:

<nav aria-label="Breadcrumb" class="mdsite-breadcrumb"></nav>

If you specify the --no-nav flag, this wrapper is omitted.

{{breadcrumb --no-nav}}

{{inputpath}}

Expands to the path of the source file within INPUTDIR. The path begins with a slash, e.g. /foo/index.md.

This comes in handy, e.g. if you want each page to link to its source file on GitHub.

{{macro ...args}}

Expands to the literal ...args. For example, {{macro foo bar}} expands to {{foo bar}}. Quotes are preserved, so {{macro foo "bar"}} expands to {{foo "bar"}}

Ben Christel made this with mdsite.