Add option to display title instead of filename

Use case or problem

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.

1 Like

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.

1 Like

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.

Another alternative is to use GitHub - Snezhig/obsidian-front-matter-title: Plugin for Obsidian.md if you’re wiling to maintain a title: property in the YAML frontmatter.

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?

1 Like