An addon for Trilium Notes to easily import SingleFile html pages.
Note: Due to the non-standard APIs and globals used, consider this addon in beta. I expect many issues to be found.
trilium_pV3BQlLeXt.mp4
- Easily import SingleFile pages via drag and drop
- SingleFile pages are saved in Trilium unedited
- Preview them directly in Trilium with a fancy pseudo-browser UI
- Fancy in-app settings UI
- Multiple settings and customization
There are some features specific to the desktop client of Trilium.
- Watch a local folder for newly added SingleFile pages
- Customize which folder to watch as well as a toggle to enable/disable
- Download the
zipfile from the latest release on GitHub. - In Trilium, right-click the note where you want to install the plugin and choose Import into note.
- Select the downloaded
zipfile, uncheckSafe Import, and click Import.⚠️ Safe Importmust be disabled because the plugin uses custom JavaScript that Trilium would otherwise strip out.
After importing, you will see a new note called Trilium SingleFile in your note tree. This note is a render note — it contains the plugin UI and acts as the main entry point.
⚠️ Trilium 0.63+ automatically adds a#disabledlabel to imported scripts and render notes as a security measure. If the plugin UI does not appear when you click the Trilium SingleFile note, you need to remove this label from the following notes.
💡 The plugin's child notes (
Main JS,Settings, etc.) are hidden by default because they are tagged#archived. To see them, enable Show archived notes in Trilium's left panel, or expand the Trilium SingleFile note in the tree.
- In your note tree, click Trilium SingleFile (the root plugin note).
- Open its Owned Attributes (click the
</>button on the toolbar, or press Alt+A). - Find the
#disabledlabel and delete it.
- Open its Owned Attributes (click the
- Expand Trilium SingleFile and click Main JS (the JavaScript child note tagged
#triliumSingleFile=main).- Open its Owned Attributes the same way.
- Find the
#disabledlabel and delete it.
- Click Settings (the child note tagged
#triliumSingleFile=settings).- Remove the
#disabledlabel from its Owned Attributes as well.
- Remove the
- Reload the Trilium SingleFile note — the plugin UI should now appear.
The plugin creates the following note structure automatically (all child notes are hidden with #archived):
Trilium SingleFile ← render note (plugin entry point, tagged #triliumSingleFile=ui)
│ ~renderNote → UI HTML
├── Settings ← plugin settings store (#triliumSingleFile=settings, #run:frontendStartup)
├── Main JS ← plugin logic (#triliumSingleFile=main, #run:frontendStartup)
├── UI HTML ← render template for the plugin UI (#triliumSingleFile=ui.html)
│ └── UI JS ← UI JavaScript (#triliumSingleFile=ui.js)
└── Renderer HTML ← render template for saved pages (#triliumSingleFile=renderer)
└── Renderer JS ← renderer JavaScript (#triliumSingleFile=renderer.js)
When you import a SingleFile page, the plugin automatically creates:
<your inbox note>
└── <Page Title> ← render note (tagged #singleFilePreview)
~renderNote → Renderer HTML
└── SingleFile Page ← raw HTML source (tagged #singleFileSource, hidden with #archived)
The plugin uses two different ~renderNote relations:
- The root Trilium SingleFile note's
~renderNotepoints to UI HTML — this renders the plugin's own drag-and-drop interface. - Each imported page's
~renderNotepoints to Renderer HTML — this is what displays the saved page in the pseudo-browser UI.
You do not need to create either relation manually — the plugin sets them automatically.
By default, imported pages are placed into a daily note. To organize imports into a specific note instead:
- Open the note you want to use as your inbox in Trilium.
- Add a label attribute
#singleFileInboxto that note (click + in the note's attribute panel, choose Label, and entersingleFileInbox).
The plugin will then place all new imports as children of that note. If no #singleFileInbox note is found, it falls back to a note labelled #inbox, and then to the current daily note.
Since every install of this plugin has a new renderer html and js (though there's not always guaranteed to be changes), there was some functionality added into the plugin to make migrating to new versions a little easier.
- Install the new version using the steps from above.
- Delete the old version of the plugin note.
- Open the new Trilium SingleFile note.
- Scroll to the bottom of the plugin UI.
- Click "Fix ~renderNote Attributes".
This re-points the ~renderNote relation on all your existing saved pages to the new renderer. Until this is done, previously saved pages may not render correctly.
Once this is considered more stable, the plugin will prompt you with this as soon as you install so you don't have to remember to do it.
- New imports are automatically placed into your
#singleFileInbox- If there's no note with
#singleFileInboxattribute then it uses#inbox - If there's no
#inboxthen it uses a daily note
- If there's no note with
- Use the UI to customize your settings at any time!
- All render notes will be given
#singleFilePreview - All SingleFile notes will be given
#singleFileSource
| Label | Applied to | Purpose |
|---|---|---|
#singleFileInbox |
Any note you choose | Designates the inbox note for new imports |
#singleFilePreview |
Each imported page's render note | Lets you search/find all saved pages |
#singleFileSource |
The raw HTML child note | Marks the source HTML; also tagged #archived so it stays hidden |
#archived |
All plugin child notes & raw HTML source notes | Hides notes from the note tree by default |
#triliumSingleFile=ui |
The root Trilium SingleFile note | Internal — entry point for the plugin UI |
#triliumSingleFile=settings |
The Settings child note | Internal — stores your saved settings |
#triliumSingleFile=main |
The Main JS child note | Internal — plugin logic with #run:frontendStartup |
#triliumSingleFile=ui.html |
The UI HTML child note | Internal — HTML template for the plugin's drag-and-drop UI |
#triliumSingleFile=ui.js |
The UI JS child note | Internal — JavaScript for the plugin UI |
#triliumSingleFile=renderer |
The Renderer HTML child note | Internal — render template used by every imported page |
#triliumSingleFile=renderer.js |
The Renderer JS child note | Internal — JavaScript for the page renderer |
- Click on the render note called Trilium SingleFile in your note tree.
- The plugin UI opens in the main pane — you will see a drop zone.
- Drag and drop any SingleFile
.htmlpage into the drop zone.
Saving pages with SingleFile: Install the SingleFile browser extension, then click its icon on any page to save a self-contained
.htmlfile. That file is what you drag into the plugin.
- Open the Trilium SingleFile note and go to settings.
- Enable the file watcher and set the folder to watch (defaults to your Downloads folder).
- Save a webpage using the SingleFile browser extension — the file will be automatically imported once detected in the watched folder (detection may take a few moments).
Check out my other Trilium-based projects:
- Trilium Markdown Preview
- Trilium LaTeX Preview
- Trilium Breadcrumbs
- Trilium SingleFile
- Trilium Types
- Trilium ETAPI
- Trilium Pack
Want more? Be sure to check out the Awesome Trilium list!