statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.

Home Page:https://statiq.dev/web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Include example

AlexHedley opened this issue · comments

Do you have examples of the different shortcodes?

I'll like to use the include to create a Table of Contents, once, and use it in other posts.

I created another markdown file toc.md and put it in another directory inputs/includes.

Added the following to my post:

<?# Include "./../includes/posts/toc.md" /?>

But when built the site it added it as raw text not markdown.

Is there another attribute I need to set?

Should it be

<?! Include "./../includes/posts/toc.md" /?>

https://www.statiq.dev/guide/content-and-data/shortcodes#processing-phases

  • Pre-rendering:

Performed before any other templating engines like Markdown or Razor. That means any output from a shortcode in this phase will be processed by those engines. For example, if you want to include a Markdown document in another Markdown document, you'll need to evaluate the Include shortcode during the pre-rendering phase (otherwise the Markdown processor would have already been run and your included Markdown document would never get processed).

Alternative

Relative

<?# Markdown ?>
<?!^ "./../includes/posts/toc.md" /?>
<?#/ Markdown ?>

Absolute

<?# Markdown ?>
<?!^ "https://raw.githubusercontent.com/alex-hedley/statiqweb-example/main/src/includes/posts/toc.md" /?>
<?#/ Markdown ?>