Include Note

Text notes can "include" another note as a read-only widget or an interactive widget, depending on the type of note.

This can be useful for e.g. including a dynamically generated chart (from scripts & "render HTML" note) or other more advanced use cases.

Including a note

In the Formatting toolbar, look for the  button. There is also a keyboard shortcut defined for it but it is not allocated by default.

The Include note dialog opens in a popup next to the cursor on desktop, with two rows: Note, where you search for the note to include, and Box size (see Box sizes below), a row of buttons each with a small drawing of the size, with a sentence under it describing the size chosen. Once a note is picked, press Include note or Enter to include it. Typing the title of a note that does not exist offers to create it.

An image note, a Canvas or a Mermaid Diagrams note picked in the dialog is inserted as an image rather than included, so instead of the size buttons, the Box size row says so. In a text note, the image can be resized once it is in the text, and the dialog reminds you of that, as it reminds you that the size of an include can be changed later.

To include a note that is already linked, right-click a reference link to it in a text note being edited and select Convert link to an included note, at the end of the menu. The include gets the box size that suits the note, as one added from the button does.

An attachment can be included the same way, from the context menu of a link to it (see Embedding an attachment there).

A link to blocks of a text or Markdown note is converted the same way, with Convert link to note excerpt, and the include then shows only those blocks. See Block references.

Box sizes

The box size sets how much of the included note is shown, and whether the box can be resized.

  • Compact shows a single row instead of the content: the note's icon, its title with the path to the note above it, and buttons to act on the note. The included note is never rendered, so wherever the note is shown outside the editor, such as in print, in a tooltip or on a shared page, a Compact include appears as a link to the included note. An included audio file is the exception: its Compact box is a row of player controls, without a title until Show title is turned on.
  • Resizable shows the content in a box that can be resized to any width and height (see Resizing below). Text scrolls inside the box, while a picture, a diagram or a video is scaled down to fit it. Until it is resized, the box takes the full width of the note and about 20 lines of height.
  • Full shows the whole content, at the full width of the note.
  • Expandable shows only the title until its arrow is pressed. In a read-only note, a click anywhere on the title row other than its buttons and link expands or collapses it as well. It takes the full width of the note, and its height can be resized once it is expanded.

A new include gets the size that suits what it shows:

  • Compact for a note or an attachment that has no preview, such as a relation map or an archive, and for audio.
  • Full for a code note or a code file, such as a .js, .py or .txt attachment, and for an excerpt of the blocks of a text or Markdown note.
  • Resizable for anything else.

The Include note dialog selects that size among its Box size buttons once the note is picked, and you can choose another one there. To change the size later, select the include and use the Box size menu in its toolbar, or the Size submenu of its More actions menu. Both have Default, which puts the include back at the size it started with, without a resized width or height; it is unavailable while the include is already there. For an included code or Markdown note and an embedded code or Markdown file, the Box size menu is the button, whose tooltip names the current size.

Resizing

A Resizable include can be resized to any width and height, and an Expandable include in height. A Compact or Full include always fits its content.

  • To resize an include, select it and drag the handle in its bottom-right corner. To change only the width or only the height, drag the middle of its right or bottom edge instead, where a touch screen shows a handle too. In right-to-left text, the handle is in the bottom-left corner and the width changes from the left edge.
  • Resizing works with a mouse, a pen or a finger.
  • While the height changes, moving the handle near the top or the bottom of the note scrolls the note.
  • An include narrower than the note is centered, so changing its width moves both of its sides. An include aligned to the left or the right keeps that side in place and has its handles on the other side (see Positioning below). Making an include as wide as the note returns it to the full width.
  • To cancel a resize, press Esc before releasing the handle.
  • To reset the size, double-click the corner handle, or double-tap it on a touch screen. Double-clicking the right or bottom edge resets only the width or the height.
  • Choosing Compact or Full removes the resized width and height, and choosing Expandable removes the width, as it takes the full width of the note. Resizable keeps both, and Default removes both.
  • While an Expandable include is collapsed, it cannot be resized.

Positioning

An include can sit on lines of its own or have the text wrap around it, as an image can.

  • To change the position, open the More actions menu of the include in a note being edited (see Opening an included note below) and choose an entry of its Position submenu:
    • Under Break text, Align left, Align center and Align right place the include on lines of its own, at that side of the note. Align center is the default.
    • Under Wrap text, Align left and Align right place the include at that side and let the text run beside it.
  • Only a Resizable include can be placed in the text. It takes the full width of the note until it is resized, so a new position shows once it is resized narrower (see Resizing above). An Expandable include takes the full width and offers the Break text positions alone, which align the content inside its box. A Compact or Full include has no Position submenu. A position is kept through a change of box size, and shows again once the include is Resizable.
  • In the mobile layout, an include with a position other than Align center takes the full width, and only its height can be resized.

Caption

An include can have a caption, shown centered at the bottom of its box. The caption is part of the text note, so it can be formatted like the rest of the text, for example in bold or with a link.

  • To add a caption, select the include, press the Toggle caption on button in its toolbar and type the caption. While the cursor is in the caption, the include stays selected and keeps its toolbar.
  • To remove the caption, press the same button again. Pressing it once more brings back the text it had, as long as the note stays open.
  • A Compact include has no caption, unless it is an audio file. Switching an include to Compact removes its caption, and switching it back to a larger size restores the caption, as long as the note stays open.
  • An Expandable include shows its caption under the title while the content is collapsed, and under the content once it is expanded.

Title

The title row of an include links to the included note and holds its buttons. To show only the content, turn off Show title in the menu of the include, which right-clicking the title row or pressing its More actions button opens (see Opening an included note below).

  • While the title is hidden, select the include and press the More actions button in its toolbar to open the same menu, where turning on Show title shows the title again.
  • A Compact or Expandable include always shows its title, so Show title is unavailable in its menu. An audio file at Compact is the exception: it starts without its title, which Show title shows above its controls.

Opening an included note

To open an included note in a new tab, press the Open in new tab button at the end of its title. An embedded attachment has the same button.

The More actions button at the end of the title row opens the same menu as right-clicking anywhere on the title row: the other places to open the note in and, for an embedded attachment, the actions on the attachment.

In a note being edited, the menu also has the Size submenu, Show title and Show caption, each a switch that is on while it is in effect, and the Position submenu after Size (see Positioning above). The menu ends with Delete block, which removes the include from the note, followed by Convert to link. For an embedded attachment, Delete attachment... follows Delete block, and Convert attachment into note... follows Convert to link. A drawing canvas, a Mermaid diagram, an included text, code or Markdown note and an embedded code or Markdown file also have Editable, above Size. An included code or Markdown note, an embedded code or Markdown file and a Mermaid diagram also have the Word wrap and Line numbers submenus after Editable (see Editing an include in place below). A Mermaid diagram, an included Markdown note and an embedded Markdown file also have Source view, Split view and Preview after these submenus. For an embedded attachment they follow its first group of actions; for an included note, the places to open it in.

To show an include of size Resizable or Full on the whole screen, press the Fullscreen button at the end of its title. An excerpt of the blocks of a text note has an Edit excerpt button there instead; see Block references. To return, press Exit fullscreen in the top-right corner, or Esc.

A Compact include has these buttons instead, followed by the same More actions button:

  • For a note, Quick edit opens the note in Quick edit, and Open in new tab opens it in a new tab.
  • For an embedded attachment, Open externally opens the file in another application, and Download downloads it. The size of the file is shown under its title.

To replace an include with a link to the included note, choose Convert to link in the last group of its More actions menu. An embedded attachment turns into a link to the attachment the same way.

Includes inside an included note

The includes of an included note show as Compact boxes, whatever their own box size: a row with the icon and title of the note, and buttons to open it, but not its content. This keeps a note that includes notes which include further notes, such as a journal built from templates, quick to open. Opening the included note shows its own includes at the box size they were given.

An include of a note that is already shown around it shows as a link to that note instead. For example, if note A includes note B and B includes A, opening A shows B in a box, and inside that box a link back to A.

Missing notes and attachments

An include whose note or attachment no longer exists, for example because it was deleted, keeps its size and shows the icon in place of the content, with the ID of the missing note or attachment. To remove the include, select it and press Delete.

Content added by a newer version of Trilium, which this version cannot show, appears the same way with the icon. Editing the note keeps that content unchanged, so it shows again once Trilium is updated.

Included notes in the share functionality

If a shared note contains one or more included notes, they will be displayed in the content of the note as if they were part of the note itself. An include resized narrower than the note keeps its width and its position. On a narrow screen, an include with a position other than Align center takes the full width. The caption of an include is shown under the included content. An Expandable include shows its title and stays collapsed until it is clicked, with its caption under the title until then. Its headings are left out of the page's table of contents. A Compact include is shown as a link to the included note instead, and so is an include that would show a note already shown around it, such as a note that includes itself. The same goes for a printed or exported note.

An included video or audio file, whether a note or an attachment, plays in the browser's player.

For this to work, the included notes must also be shared. However, they can still be hidden from the note tree via #shareHiddenFromTree.

An include whose note or attachment is missing or not shared shows This content is not available in its place, and so does content added by a newer version of Trilium.

Interactive notes

Since v0.104.0, included notes might become interactive depending on their note type:

  • Collections (e.g. Geo Map) will render fully interactive, including creating new notes.
  • Saved Search will also display the results.
  • Web View provides an interactive preview of the website.

Included images

An included image, whether an image note or an image attachment, is shown in the image viewer, which zooms and pans it:

  • To zoom, press the Zoom in and Zoom out buttons in the bottom-right corner of the image, or pinch on a touch screen. The percentage between them resets the zoom.
  • To zoom with the mouse wheel, click the image first. Until then, the mouse wheel scrolls the note.
  • To pan an image that is zoomed in, drag it. At its fitted size, dragging the image on a touch screen scrolls the note.
  • To return to the fitted size, double-click the image.

In a Resizable box, the image is scaled down to fit the height of the box. In fullscreen, it fits the screen.

Editing an include in place

An included text note, an included code note and an embedded code file such as a .js, .py or .txt attachment can be edited without leaving the note that includes them. Until then, a code note or file is shown read-only in the code editor, where its code can be selected and copied, and its blocks folded and unfolded with the arrows in its gutter. Included Markdown can be edited too, see Included Markdown below.

  • To edit, select the include and turn on the Editable button at the start of its toolbar, or turn on Editable in its More actions menu. Turn Editable off to stop editing.
  • While Editable is on, the arrow keys move the caret into the include and back out, as through the rest of the text. Entering from above or from the left puts the caret at the start of the include, and entering from below or from the right puts it at the end. A collapsed Expandable include is skipped.
  • While an included text note has the focus, the formatting toolbar applies to it. The notes it includes in turn stay read-only.
  • Code is edited in the same code editor as a Code note, with its theme, indentation and line wrapping settings.
  • Typing / in the code lists the Code Snippets of its language, as in a code note.
  • The toolbar of an included code note or an embedded code file also has the language and indentation menus of the Status bar, between Editable and the Box size menu: Change language mode, which shows the current language, and Change tab width, which shows the current indentation. Re-indent content to converts the indentation of the code itself and saves it to the included note or file, whether Editable is on or off.
    • For an included note, the menus change the note, as they do in its own tab.
    • For an embedded code file, the language and indentation settings change only how this include shows the file, and are saved with the note that includes it. The language replaces the one that the file name gives, and the Use default entries return to the indentation set in Options → Code Notes. These settings leave the file itself unchanged, and other includes of it keep their own settings.
  • The More actions menu of an included code or Markdown note, an embedded code or Markdown file and a Mermaid diagram has two more submenus after Editable, each with Auto, On and Off. They change how the code editor shows the source.
    • Word wrap wraps long lines instead of scrolling them. Auto follows the setting in Options → Code Notes. For an included note, it sets the #wrapLines label of the note, as the Word wrap submenu of its Note menu does for a code note. For an embedded file or a Mermaid diagram, it changes only this include.
    • Line numbers shows or hides the numbers at the start of each line. Auto follows the setting in Options → Code Notes. It changes only this include, for an included note as well.
  • The changes are saved as you type, to the included note or to the attachment, as they would be in its own tab.
  • The changes made in the code editor of an include are part of the undo history of the note that includes it, together with the changes to its text, in the order they were made. This includes the source of included Markdown and of a Mermaid diagram, and the changes to a drawing canvas (see below).
    • Ctrl+Z undoes the last change of the note, and Ctrl+Y or Ctrl+Shift+Z redoes it, whether the caret is in the text or in an include, and also while Editable is off. The Undo and Redo buttons of the formatting toolbar do the same. With the Vim key bindings, u and Ctrl+R in an include do the same too.
    • The focus moves to the change that was undone or redone: into the code editor or the drawing canvas of the include, or back to the text.
    • Undoing a change of an included note saves the included note again. Once the included note has been changed elsewhere, for example in another tab, its earlier changes can no longer be undone from here, and undo skips them.
    • An included text note keeps an undo history of its own.
  • An include of Block references edits only the referenced blocks.
  • Editing is not available in a read-only note, for an included note marked #readOnly, or for an attachment of another note.
  • Search in note finds the text of included text and code notes among the results of the note around them, and replaces it while Editable is on.

Included Markdown

An included Markdown note and an embedded Markdown file, such as a .md attachment, are shown with the same three views as a Markdown note in its own tab (see Note types with split view): Source view, Split view and Preview.

  • To switch the view, press one of the three buttons in the title row of the include. In a note being edited, the toolbar of the include has the same buttons after Editable, and its More actions menu has them as Source view, Split view and Preview.
  • Until a view is chosen, the include shows the Preview, and the Split view while Editable is on.
  • To edit the Markdown, turn on Editable (see Editing an include in place above). The source is edited in the code editor of a Markdown note, and the preview follows the changes as you type. While Editable is off, the source can be read and copied but not changed.
  • The source has the slash commands and the @ and [[ note links of a Markdown note. A note created from the @ or [[ list goes under the included note, or for an embedded file under the note that includes it, and /image uploads the image to that same note.
  • The Word wrap and Line numbers submenus of the More actions menu change how the source shows, as for code (see Editing an include in place above).
  • As in a Markdown note, the preview scrolls along with the source and highlights the block where the cursor is, and Ctrl+B, Ctrl+I, Ctrl+M and Ctrl+Shift+X format the selection.
  • In a note being edited, the view is saved with the include, so two includes of the same note can show different views. In a read-only note, the view can be changed too, until the note is opened again.
  • While the source shows, and wherever the Markdown can be edited, the include has the height of its box size, or the height it was resized to, so turning Editable on or off keeps its size. Otherwise, as in a read-only note, the preview fits its text up to that height. A Full include fits its content instead.
  • Search in note searches the source while it shows, and the preview otherwise.

Drawing canvases

A drawing canvas is an Excalidraw canvas, like the one of a Canvas note, drawn directly in the text note. It is not a note of its own: the drawing is kept in a Canvas.excalidraw attachment of the text note and is saved together with the text.

  • To insert a drawing canvas, open the Insert menu of the Formatting toolbar and choose Drawing canvas, above Mermaid diagram. It is also available as Drawing canvas in the Slash Commands. The canvas is added empty and editable, in a Resizable box with its title hidden, and takes the focus, ready for drawing.
  • To draw or write over an image, select the image and press the Convert image to a drawing canvas button of its toolbar. The image is replaced by an editable drawing canvas in a Resizable box, with its title hidden and the focus in it. The image sits at its original size in the middle of the canvas, zoomed so that all of it shows, and is locked so that it cannot be selected or moved by accident. While it is locked, the canvas can be zoomed in on the image but not zoomed out past it or scrolled beyond its edges. To move or resize the image anyway, right-click it and choose Unlock. The caption of the image is kept, but not its alignment or link. Only an image on its own line can be converted, not one inside a paragraph. Undo brings the image back.
  • An Excalidraw file (.excalidraw) attached with Attach and embed file, under the Attach file button, becomes a drawing canvas too, in a Resizable box titled with the file name. It starts with Editable off, so the drawing shows but cannot be changed until Editable is turned on (see below).
  • To draw on a canvas that does not have the focus, click it first. The canvas then has the tools, menus and keyboard shortcuts of a Canvas note. The toolbars, the menus and the properties of the selected shapes show only while the canvas has the focus, so elsewhere the drawing reads like a picture in the text.
  • The mouse wheel and the touchpad scroll the note over a canvas too, as over the text. To zoom, use the zoom buttons of the canvas toolbar. The percentage between them opens a menu with Zoom to fit, which shows the whole drawing, and Reset zoom. To move around the drawing, use the Hand tool. The zoom and position are saved with the drawing, so the canvas opens again where it was left, wherever the note is shown. In fullscreen, the mouse wheel moves and zooms the drawing instead.
  • The canvas keeps the size it was drawn at. In a narrower note, for example on a phone, it shrinks down to three quarters of that size, then scrolls sideways instead. The resize handle shows more or less of the drawing at the same zoom, and Full widens it across the note. Fullscreen has a zoom and position of its own and leaves those of the canvas as they were.
  • The No tool button, first among the tools of the canvas toolbar, leaves the drawing alone: the mouse does nothing on it, and a touch gesture over it scrolls the note instead of drawing on, selecting or moving the drawing. In the mobile layout, a canvas starts with no tool and returns to it whenever it loses the focus, so that the note scrolls over its drawings until a tool is picked. Fullscreen has no use for it: a canvas with no tool switches to the Selection tool as it goes fullscreen.
  • The canvas toolbar replaces the Excalidraw menu: Export image, Find on canvas, Library and Help are at the end of its More tools menu. In fullscreen, the Excalidraw menu shows again. In the mobile layout, the canvas toolbar is in the formatting toolbar at the bottom of the screen, behind the Canvas › button.
  • Search in note finds the text of the drawing among the results of the note and highlights each result on the canvas, which moves only to show a result outside its view. Inside a canvas, the shortcut of the search, Ctrl+F on desktop, opens it instead of the Excalidraw search, which stays available as Find on canvas.
  • The changes to the drawing are part of the undo history of the text note (see Editing an include in place above). Ctrl+Z, Ctrl+Y and the Undo and Redo buttons of the canvas toolbar undo and redo the last change of the note, in the drawing or in the text.
  • A new drawing has the background color of the note. A background chosen from the Excalidraw menu replaces it.
  • To protect a finished drawing from accidental changes, select it and turn off Editable in its More actions menu. The drawing then shows as a still picture, at the zoom and position it had, and can no longer be changed, zoomed or moved. To draw again, turn on the Editable button at the start of its toolbar, which shows only while Editable is off, or turn Editable back on in the menu.
  • The box sizes, resizing, the caption and the title work as for an included note, but the toolbar of a drawing leaves the box size and the position to its More actions menu (see Positioning above). A Compact drawing canvas shows its title row alone, without the drawing.
  • In the desktop layout, Excalidraw keeps its desktop interface however small the box is. In the mobile layout, a narrow or short box switches it to a compact interface. For more room, choose Full, or show the title and press Fullscreen.
  • In the compact interface, the buttons for the selection are on a rail at the side of the screen while the canvas has the focus, so they stay in reach wherever the canvas is scrolled: Edit opens the properties of the selected shapes or of the chosen tool in a panel at the bottom of the screen, above the formatting toolbar, Duplicate and Delete act on the selected shapes, and Done finishes a line or an arrow drawn point by point. The rail shows only the buttons that apply, and leaves when none does. The properties close when the selection is cleared, and open again only with Edit. In fullscreen, these buttons are at the bottom of the canvas instead.
  • Pictures added to the drawing are stored in the same attachment. A converted image is kept as an image attachment of the note instead, named with a generated code.
  • In a read-only note, the drawing shows as a still picture too, with a gray box in its place until it is drawn.
  • On a shared page, the drawing is shown as the same picture, in light or dark colors to match the page. Each change to the drawing saves this picture as an SVG image attachment of the note, also named with a generated code, which the list of attachments shows under Generated by Trilium.

Limitations

  • The Excalidraw shape library is not saved for a drawing canvas.
  • Outside the editor, for example in a tooltip, when printing or in the list of attachments, the drawing is shown as a picture.
  • A drawing has no picture for shared pages until its first change, except one converted from an image. Until then, for example for an attached .excalidraw file, a shared page shows a link to download the drawing instead.
  • In Safari, the picture of a drawing on a shared page follows the light or dark appearance of the system rather than the theme chosen on the page.
  • A copy of a drawing canvas pasted in the same note shares the drawing with the original, zoom and position included. A copy pasted in another note gets a drawing of its own.