Bug description
When a folder note is created with a template path configured, the template is never applied to the new file. The file is created empty (0 bytes).
Root cause (from source analysis)
I traced the issue through the plugin source code:
-
createFolderNote creates the file empty via vault.create(path, "") (in handleCreateFolderNote, the template logic at line ~3218 is gated by extension !== ".md", so it's skipped for markdown folder notes).
-
applyTemplate is then called, which correctly finds the template file and detects Templater is enabled.
-
applyTemplate calls templaterPlugin.write_template_to_file(templateFile, file) — this call completes without error but silently does nothing. The file remains empty.
Additionally, Templater's trigger_on_file_creation does not fire for files created by Folder Notes. When the Folder Notes template path is cleared and Templater's catch-all / folder template is configured, the folder note is still created empty. This suggests vault.create() as called by Folder Notes does not trigger the event that Templater listens for.
Two separate issues
write_template_to_file silently fails: Templater's read_and_parse_template likely returns null in this calling context, causing the function to exit early without writing anything. No error is logged.
trigger_on_file_creation not firing: Files created by Folder Notes do not trigger Templater's new-file event, so even with the template path cleared, Templater's folder template mappings are bypassed.
Steps to reproduce
- Install Folder Notes and Templater
- Create a template file (e.g.,
Templates/folder-note.template.md) with any content
- In Folder Notes settings → General → Template path, select the template
- In Templater settings, enable "Trigger Templater on new file creation"
- Right-click a folder → Create folder note
- The created note is empty — template not applied
Debug output
Added console.log statements to applyTemplate in main.js:
[folder-notes-debug] callsite: {folderNote: true, matchingExtension: true, extension: '.md', templatePath: 'Templates/folder-note.template.md', folderNoteType: '.md'}
[folder-notes-debug] applyTemplate called {filePath: 'Health/Supplements/Supplements.md', templatePath: 'Templates/folder-note.template.md'}
[folder-notes-debug] fileContent: "" length: 0
[folder-notes-debug] templateFile: Templates/folder-note.template.md found: true isTFile: true
[folder-notes-debug] plugins: {templaterEnabled: true, templatesEnabled: true, hasTemplaterPlugin: true}
[folder-notes-debug] templateContent length: 109
[folder-notes-debug] calling write_template_to_file
[folder-notes-debug] write_template_to_file returned: undefined
All checks pass, the template file is found and read, but write_template_to_file produces no output.
Environment
- Folder Notes: v1.8.19
- Templater: v2.16.4
- Obsidian: desktop, macOS
- File type:
.md
Bug description
When a folder note is created with a template path configured, the template is never applied to the new file. The file is created empty (0 bytes).
Root cause (from source analysis)
I traced the issue through the plugin source code:
createFolderNotecreates the file empty viavault.create(path, "")(inhandleCreateFolderNote, the template logic at line ~3218 is gated byextension !== ".md", so it's skipped for markdown folder notes).applyTemplateis then called, which correctly finds the template file and detects Templater is enabled.applyTemplatecallstemplaterPlugin.write_template_to_file(templateFile, file)— this call completes without error but silently does nothing. The file remains empty.Additionally, Templater's
trigger_on_file_creationdoes not fire for files created by Folder Notes. When the Folder Notes template path is cleared and Templater's catch-all/folder template is configured, the folder note is still created empty. This suggestsvault.create()as called by Folder Notes does not trigger the event that Templater listens for.Two separate issues
write_template_to_filesilently fails: Templater'sread_and_parse_templatelikely returnsnullin this calling context, causing the function to exit early without writing anything. No error is logged.trigger_on_file_creationnot firing: Files created by Folder Notes do not trigger Templater's new-file event, so even with the template path cleared, Templater's folder template mappings are bypassed.Steps to reproduce
Templates/folder-note.template.md) with any contentDebug output
Added
console.logstatements toapplyTemplateinmain.js:All checks pass, the template file is found and read, but
write_template_to_fileproduces no output.Environment
.md