From 888d0d10846d55c44c6b3f438f774303db53cfd1 Mon Sep 17 00:00:00 2001 From: Kevin Leutzinger <6435727+kleutzinger@users.noreply.github.com> Date: Wed, 1 Oct 2025 03:46:08 -0400 Subject: [PATCH] add docs about shareHtml and shareHtmlLocation --- .../Advanced Usage/Attributes/Relations.md | 1 + .../User Guide/Advanced Usage/Sharing.md | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md b/docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md index 2916640ec..454e7d007 100644 --- a/docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md +++ b/docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md @@ -50,5 +50,6 @@ These relations are supported and used internally by Trilium. | `widget_relation` | target of this relation will be executed and rendered as a widget in the sidebar | | `shareCss` | CSS note which will be injected into the share page. CSS note must be in the shared sub-tree as well. Consider using `share_hidden_from_tree` and `share_omit_default_css` as well. | | `shareJs` | JavaScript note which will be injected into the share page. JS note must be in the shared sub-tree as well. Consider using `share_hidden_from_tree`. | +| `shareHtml` | HTML note which will be injected into the share page at locations specified by the `shareHtmlLocation` label. HTML note must be in the shared sub-tree as well. Consider using `share_hidden_from_tree`. | | `shareTemplate` | Embedded JavaScript note that will be used as the template for displaying the shared note. Falls back to the default template. Consider using `share_hidden_from_tree`. | | `shareFavicon` | Favicon note to be set in the shared page. Typically you want to set it to share root and make it inheritable. Favicon note must be in the shared sub-tree as well. Consider using `share_hidden_from_tree`. | \ No newline at end of file diff --git a/docs/User Guide/User Guide/Advanced Usage/Sharing.md b/docs/User Guide/User Guide/Advanced Usage/Sharing.md index 37ce5fee8..793389ae2 100644 --- a/docs/User Guide/User Guide/Advanced Usage/Sharing.md +++ b/docs/User Guide/User Guide/Advanced Usage/Sharing.md @@ -67,6 +67,23 @@ The default design should be a good starting point, but you can customize it usi You can inject custom JavaScript into the shared note using the `~shareJs` relation. This allows you to access note attributes or traverse the note tree using the `fetchNote()` API, which retrieves note data based on its ID. +### Adding custom HTML + +You can inject custom HTML snippets into specific locations of the shared page using the `~shareHtml` relation. The HTML note should contain the raw HTML content you want to inject, and you can control where it appears using the `#shareHtmlLocation` label. + +The `#shareHtmlLocation` label accepts values in the format `location:position`: +- **Locations**: `head`, `body`, `content` +- **Positions**: `start`, `end` + +For example: +- `#shareHtmlLocation=head:start` - Injects HTML at the beginning of the `
` section +- `#shareHtmlLocation=head:end` - Injects HTML at the end of the `` section (default) +- `#shareHtmlLocation=body:start` - Injects HTML at the beginning of the `` section +- `#shareHtmlLocation=content:start` - Injects HTML at the beginning of the content area +- `#shareHtmlLocation=content:end` - Injects HTML at the end of the content area + +If no location is specified, the HTML will be injected at `content:end` by default. + Example: ```javascript @@ -106,7 +123,7 @@ To do so, create a shared text note and apply the `shareIndex` label. When viewe ## Attribute reference -Attribute | Description |
---|---|
shareHiddenFromTree | this note is hidden from left navigation tree, but still accessible with its URL |
shareExternalLink | note will act as a link to an external website in the share tree |
shareAlias | define an alias using which the note will be available under https://your_trilium_host/share/[your_alias] |
shareOmitDefaultCss | default share page CSS will be omitted. Use when you make extensive styling changes. |
shareRoot | marks note which is served on /share root. |
shareDescription | define text to be added to the HTML meta tag for description |
shareRaw | Note will be served in its raw format, without HTML wrapper. See also Serving directly the content of a note for an alternative method without setting an attribute. |
shareDisallowRobotIndexing | Indicates to web crawlers that the page should not be indexed of this note by:
|
shareCredentials | require credentials to access this shared note. Value is expected to be in format username:password . Don't forget to make this inheritable to apply to child-notes/images. |
shareIndex | Note with this label will list all roots of shared notes. |
Attribute | Description |
---|---|
shareHiddenFromTree | this note is hidden from left navigation tree, but still accessible with its URL |
shareExternalLink | note will act as a link to an external website in the share tree |
shareAlias | define an alias using which the note will be available under https://your_trilium_host/share/[your_alias] |
shareOmitDefaultCss | default share page CSS will be omitted. Use when you make extensive styling changes. |
shareRoot | marks note which is served on /share root. |
shareDescription | define text to be added to the HTML meta tag for description |
shareRaw | Note will be served in its raw format, without HTML wrapper. See also Serving directly the content of a note for an alternative method without setting an attribute. |
shareDisallowRobotIndexing | Indicates to web crawlers that the page should not be indexed of this note by:
|
shareCredentials | require credentials to access this shared note. Value is expected to be in format username:password . Don't forget to make this inheritable to apply to child-notes/images. |
shareIndex | Note with this label will list all roots of shared notes. |
shareHtmlLocation | defines where custom HTML injected via ~shareHtml relation should be placed. Format: location:position where location is head , body , or content and position is start or end . Defaults to content:end . |