Statiq.Web - Shortcodes - Include

How to reuse content.
Published on Sunday, 2 July 2023

https://www.statiq.dev/assets/statiq-web.svg

In another project (Symantec Connect Articles) I've got a Table of Contents (toc) for many sets of Articles. This can sometimes be a lot of information and is duplicated in each article, at the top and bottom. This isn't ideal if I need to update anything.

Seeing an Include option in Devlead.Statiq - Part 1 - Tabs I wondered if there was similar functionality already built in.

When I originally tried it, looking at other Shortcodes, it didn't work. It was showing it as plain text and not converting to markdown.

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

This can't be the only option? To the docs. Processing Phases explained what was going on.

  • Pre-rendering: <?! ShortcodeName /?>
  • Intermediate: <?^ ShortcodeName /?>
  • Post-rendering: <?# ShortcodeName /?>

I'd been using Post-rendering <?# since this is what was used on a code example. Swapping it to Intermediate worked a treat.

Looking for other examples I also found the Markdown Shortcode.

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

I prefer this as the intention is very clear.

Now all I need to do is update all my articles to use this...


Options

  • Include
  • Markdown
  • Raw
  • Embed
  • Giphy
  • Gist
  • Twitter
  • YouTube
  • Link
  • Figure
  • Table