Plugin for keeping the filename and first heading of a file in sync

thanks, your plugin is precious!!

1 Like

Do you have some steps to reproduce this?

I’ve pushed v1.4.0 with some bug fixes and frontmatter support. Please update if this issue pops up again

This is most helpful! Thanks. And thanks for the update to allow excluding files. That really made it possible for me to safely install this! :grinning:

1 Like

When I add a link in a note, then I “cmd click” on this link, it creates a file with the link as filename but then the plugin doesn’t create the title . Normal?

1.5.0 has been released today which should address this. Can you give it a try?

I love this plug in, and it is incredibly useful but I think it has been corrupting the image files that are in my vault. Here is what I tracked down this morning:

Data Loss when using Filename Header Sync

I have not looked at the code yet, but maybe add a guard to ignore any filetypes other than .md?

Thanks for reporting, this was addressed immediately and the faulty version unpublished+blacklisted. 1.5.1 has a strict guard to only act on markdown files

1 Like

Hy @sararkin

My question isn’t related about your plugin. Can you show me how did you set-up these marked lines to show in your pane.

1 Like

I believe he linked it up thread but the tool there is now deprecated and it’s just a Backlinks in Document toggle

@sararkin
I’m just a noob with javascript, but I may have found a way to improve a piece of your code.

(I don’t know how to use GitHub yet, otherwise I would make a push request or whatever it is called)

I tried putting a [[wiki-link]] in the first header, thinking the square brackets would automatically get filtered out. Instead, I was confused when only one pair of brackets was removed, and other similarly strange results.

Looking at your code, I found the culprit: the function sanitizeHeading() (line 231 in main.ts) uses replace(string, '') instead of replace(regExp, '').

I think I figured out how to do it on GitHub.

I don’t know what happen with this plugin when used with obsidian sync. When I update the H1 title, the filename is adapted, but then I have duplicate files.
Ex:
I have a note the-book.md
I open this node and change heading: # the-book becomes # B-the-book
the plugin updates automatically the filename
but then I see 2 files:

  • the-book.md
  • B-the-book.md

+2!

Synching the Frontmatter Title to the file name as an option would be a terrific benefit!

Cheers!

+3
For syncing frontmatter title.

I’m trying to have this plug-in ignore my template files, because it otherwise inserts #Untitled at the end of each new file. I’ve set the Ignore Regex Rule to /* Bins/Templates since my templates are in * Bins/Templates:
2022-02-11-1114-07
But it’s still putting #Untitled at the end of the files.

What am I doing wrong?

Thanks,
Russell

My regex rule is actually: /\* Bins/Templates

Am I dealing with the asterisk correctly?

Does it display your templates in the settings page to show that they are ignored?

I think the correct regex would be .*Bins\/Templates.*, can you give that a go?

With your regex, the templates are now displayed in the settings page. However, I’m still getting # Untitled inserted at the end of the note.

Here’s the template file:

And here’s the result:

Maybe it’s coming from some other plug-in? I’m just using the core Templates plug-in.

Thanks for your kind help!

Best,
Russell

Is the title of the document “Untitled”? You can easily test this by deactivating filename-heading-sync and see if it still happens

With filename-heading-sync DEACTIVATED, and the core Templates plug-in ACTIVATED, I get a new file with “Untitled” in the filename field, whether or not the template has an H1 heading.

With filename-heading-sync ACTIVATED, and the core Templates plug-in ACTIVATED, I get a new file with “Untitled” in the filename field AND # Untitled inserted at the end of the file, whether or not the template has an H1 heading.

It must be something unique to my setting. I’ll keep digging around, as I have time.

Thanks,
Russell

Thank you so much!