Use the first line of each file as its filename

I use an H1 at the start of every file, and I’d like to have one source of truth as to what any certain file is called. Right now I have to manage both the filename and H1 at the start of the file, to keep them in sync. I’d love a plugin option to make it so I don’t have to bother with the filename, where I can trust that the filename is always going to reflect whatever the first line says.

This is similar to Use H1 or front-matter title instead of or in addition to filename as display name, but my desire is to abstract the filename away and just use the first line as the filename always.

Thanks!

22 Likes

I’m experiencing the same problem and I would appreciate a solution. Your suggestion sounds reasonable.

I simply skip having a document title in the document itself and rely on the filename being displayed at the top. But this doesn’t translate when opening the file in another program.

3 Likes

I do the exact same thing. All my files begin with an H1. Sometimes I rename a file or decided to change the header and I end up having to make sure all headers and file names are synced.

3 Likes

For what it’s worth I noticed when using the Notation Theme, the name of the file is formatted in CSS to appear as the header of a file which I like. This way you wouldn’t need to add an H1 at the start of each file and when you update the name of the file it updates the “header” as well.

1 Like

That’s a really neat way of solving the “single source of truth” issue, but I much prefer the file itself to have a title embedded within it. Therefore I want the document content itself to be the single source of truth.

I’ve also noticed this problem with that theme when the filename is longer. I don’t know that there’s a way to work around the DOM structure to fix this at the moment.

Screen Shot 2020-06-04 at 9.53.32 AM

+1 to this feature request

Similar features are in Drafts and Notes. When making a note in either app, there is no “title” for the note. The “title” is the first line of the note.

For Obsidian we could have an optional user preference that automatically prepends the title to the first line of the note as an H1.

+1 for this feature request.

Bear does a similar thing and I found it redundant to name my files twice.

But overall, Obsidian is an incredible app!!

It’s probably not a hard task. They’re probably just prioritizing bigger requested features, like a mobile app.

Also very much would like H1 # Title inside files to be reflected in sidebar and graph display.

+1 I don’t want to type the title of the document twice.

I suggest:

  • automatically updating the name of the file based on the h1 by default
  • optionally letting users override the name of the file to something other than the h1
3 Likes

I haven’t used it myself, but a plugin exists for this: Plugin for keeping the filename and first heading of a file in sync

This unfortunately is not that easy because not all characters are available in filename

This proposal is too similar to Use H1 or front-matter title instead of or in addition to filename as display name
which at least is a bit more feasable.

As mentioned by @mgmeyers, an approximate solution is the plugin Plugin for keeping the filename and first heading of a file in sync

1 Like