and when I run :ObsidianNew test I get a file with
---
id: hello
aliases:
- test
tags: []
---
# test
as expected.
But when I run :ObsidianNewFromTemplate test and use any template (with or without the yaml metadata explicitly being in the template using {{id}}), I get
---
id: test
aliases: []
tags: []
---
# test
It seems that somehow the title is being used in place of the id in templates.
Config
require("obsidian").setup({
workspaces = {
{ name = "personal", path = "~/obsidian/personal" },
},
preferred_link_style = "markdown",
daily_notes = {
date_format = "%Y-CW%V",
alias_format = "%Y-CW%V",
default_tags = { "weekly-notes" },
},
mappings = {
-- Smart action depending on context, either follow link or toggle checkbox.
["<cr>"] = {
action = function()
return require("obsidian").util.smart_action()
end,
opts = { buffer = true, expr = true },
},
},
templates = {
folder = "templates",
date_format = "%Y-%m-%d",
time_format = "%H:%M",
},
-- Optional, customize how note file names are generated given the ID, target directory, and title.
---@param spec { id: string, dir: obsidian.Path, title: string|? }
---@return string|obsidian.Path The full path to the new note.
note_path_func = function(spec)
-- This is equivalent to the default behavior.
local path = spec.dir / tostring(spec.title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower())
return path:with_suffix(".md")
end,
-- Optional, customize how note IDs are generated given an optional title.
---@param title string|?
---@return string
note_id_func = function(title)
return "hello"
end,
})
🐛 Describe the bug
For demonstrations sake, in my config I have
and when I run
:ObsidianNew test
I get a file withas expected.
But when I run
:ObsidianNewFromTemplate test
and use any template (with or without the yaml metadata explicitly being in the template using {{id}}), I getIt seems that somehow the
title
is being used in place of theid
in templates.Config
Environment