Include

The include embedding transcludes the content of another page, or a single section of it, into the current page. See https://github.com/redimp/otterwiki/issues/547. All examples below pull from the Embedding/Include/Source page.


Include a whole page

{{include|src=/Embedding/Include/Source}}

Source

This page is the source used by the Include examples. Its sections can be transcluded into other pages, individually or as a whole.

Introduction

Hello universe. This is an introductory paragraph with a short list:

  • reuse content across pages
  • keep a single source of truth
  • edit once, update everywhere

Subsection

Hello world. This subsection has a nested heading of its own.

Details

These details belong to the subsection and are only pulled in when child sections are included.

Installation

  1. Download the package
  2. Extract the archive
  3. Run make install


Include a single section

Sections are selected by their heading anchor, the same slug used for heading links, independent of the heading level.

{{include|src=/Embedding/Include/Source|section=installation}}

Installation

  1. Download the package
  2. Extract the archive
  3. Run make install


Include a section without its heading

Use heading=false to drop the section's own heading line and pull in only its body.

{{include|src=/Embedding/Include/Source|section=subsection|heading=false}}

Hello world. This subsection has a nested heading of its own.

Details

These details belong to the subsection and are only pulled in when child sections are included.

Include a section without its sub-sections

By default child sections are included. With children=false only the content directly below the heading is transcluded (the Details sub-section is left out here).

{{include|src=/Embedding/Include/Source|section=subsection|children=false}}

Subsection

Hello world. This subsection has a nested heading of its own.


Relative source path

A src that does not start with / is resolved relative to the current page, so this page can reach its own sub-pages without spelling out the full path.

{{include|src=Include/Source|section=introduction}}

Introduction

Hello universe. This is an introductory paragraph with a short list:

  • reuse content across pages
  • keep a single source of truth
  • edit once, update everywhere


Reusing a snippet

A common use is a single-source snippet that is maintained once and reused on many pages.

{{include|src=/Embedding/Include/Snippet}}

Maintenance Note

Note

This note lives on a single page and is included wherever it is needed. Update it here once and every page that includes it stays in sync.


Error handling

An unknown page or section reports an error instead of failing silently; a missing section also lists the anchors that are available.

{{include|src=/Embedding/Include/Source|section=does-not-exist}}

include Error: include: section "does-not-exist" not found in "/Embedding/Include/Source" (available: source, introduction, subsection, details, installation).