Add a settings boolean
“Use H1 header instead of file name” (or Use first not empty line) that will display files main Header instead of the filename in each possible situation:
Tab Label
Graph
Search
File explorer
Link autocompletion - display Headers on the list and fill link with [[filename|H1 Header]]
Placeholder click filled with [[filename|H1 Header]]
There is clearly a demand for this functionality for each user (I am one of them) that want to use UIDs instead of filenames. People just have their reasons. In my opinion using Main Header as “filename” in the whole system is the easiest solution that will satisfy both sides.
Current workaround (optional)
Currently there is no workaround for this, there is one plugin front matter title that tries to do that and almost accomplishes it, but still, not all places are covered.
You can use the Filename Heading Sync plugin to achieve this functionality. It will keep the first heading of your note as the filename in sync. It also works to make the filename the first heading of your note.
You completely didn’t understand what I was asking for. I don’t want to keep synchronization with Header and filename, I want the Obsidian to display one instead of other.
Use Case:
file 1234.md with content
Header
Content
Instead of displaying on the graph, in the search view, on the file explorer, tag explorer, autocompletion, and other places filename is shown Obsidian should display Header instead of 1234.
To easily initialize a title: property based on the filename, which can then be overwritten manually, I use Templater with the following template I call @set title to filename:
<%*
/**
This:
- Inserts a title without datetime prefix in the frontmatter. This is then read by and displayed by:
- [GitHub - Snezhig/obsidian-front-matter-title: Plugin for Obsidian.md](https://github.com/Snezhig/obsidian-front-matter-title)
- [GitHub - mgmeyers/obsidian-embedded-note-titles](https://github.com/mgmeyers/obsidian-embedded-note-titles)
*/
const { update } = app.plugins.plugins["metaedit"].api;
const propName = "title";
const propValue = tp.file.title.replace(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:?\d{2}:?(?:\d{2})?(?:Z|[+-]\d{2}:?\d{2})?\s+/, '');
const file = tp.file.find_tfile(tp.file.title);
const { position, ...rest } = tp.frontmatter;
const content = tp.file.content;
let newFileContent = content.split("\n");
const isYamlEmpty = Object.keys(tp.frontmatter).length === 0 && !content.match(/^-{3}\s*\n*\r*-{3}/);
async function updateCurrentFile(someContent, someFile) {
someContent = someContent.join("\n");
await app.vault.modify(someFile, someContent);
}
if (isYamlEmpty) { // No YAML yet
newFileContent.unshift("---");
newFileContent.unshift(`${propName}: ${propValue}`);
newFileContent.unshift("---");
await updateCurrentFile(newFileContent, file);
} else if (rest[propName] === undefined) { // YAML exists but no target property exists
newFileContent.splice(1, 0, `${propName}: ${propValue}`);
console.debug(`newFileContent: ${newFileContent}`);
await updateCurrentFile(newFileContent, file);
} else { // YAML exists and a target property exists
await update(propName, propValue, file);
}
%>
Yes, I described this solution in the workaround section. But the plugin does not handle all situations. Still in autocomplete and search view and other places filenames are displayed instead of Title.
Why this functionality cant be added to the core application, as clearly seen there are several requests for UID handling?
I would also really (really) like to see this model supported as a first-class thing in Obsidian. I have a database primarily in Bear, for which I want to use Obsidian as a secondary tool. I can export the Bear database to a folder of Markdown files which almost entirely works, but the normalization of Bear titles (arbitrary strings) to filenames (much more restricted) breaks everything. A much cleaner model would be a folder where filenames are just note UIDs, but the file metadata (YAML frontmatter) encodes the title. I can rewrite links to the form [[UID|Title]] on export, but quick-open and autocomplete totally fail in this world since there are no human-readable filenames.