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

**URL:** <https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042>\
**Category:** Plugins\
**Tags:** plugin-release\
**Created:** [January 27, 2021, 8:21am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042 "2021-01-27T08:21:27Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![tonyknight](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/t/e79b87/32.png) [@tonyknight](https://forum.obsidian.md/u/tonyknight)\
**Post date:** [September 29, 2021, 7:59pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/41 "2021-09-29T19:59:22Z")

</div>

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](https://forum.obsidian.md/t/warning-data-loss-when-using-filename-header-sync-plug-in/24945)

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

---

<div class="post-metadata">

**Author:** ![sararkin](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@sararkin](https://forum.obsidian.md/u/sararkin)\
**Post date:** [September 30, 2021, 5:07am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/42 "2021-09-30T05:07:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Learner1](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/l/439d5e/32.png) [@Learner1](https://forum.obsidian.md/u/Learner1)\
**Post date:** [October 25, 2021, 12:52pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/43 "2021-10-25T12:52:09Z")

</div>

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.

 ![plugin|100](https://forum.obsidian.md/uploads/default/original/3X/7/f/7f66501dd6c89f08de7d81817f6dd163eb8c9f9e.jpeg)

---

<div class="post-metadata">

**Author:** ![darth\_obsidious](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/f17d59/32.png) [@darth\_obsidious](https://forum.obsidian.md/u/darth_obsidious)\
**Post date:** [November 5, 2021, 10:28pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/44 "2021-11-05T22:28:46Z")

</div>

> [@Learner1](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![scwunch](https://forum.obsidian.md/user_avatar/forum.obsidian.md/scwunch/32/20287_2.png) [@scwunch](https://forum.obsidian.md/u/scwunch)\
**Post date:** [November 7, 2021, 2:46pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/45 "2021-11-07T14:46:42Z")

</div>

@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.](https://github.com/dvcrn/obsidian-filename-heading-sync/pull/33)

---

<div class="post-metadata">

**Author:** ![cvanhenten](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cvanhenten/32/4965_2.png) [@cvanhenten](https://forum.obsidian.md/u/cvanhenten)\
**Post date:** [December 12, 2021, 3:38pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/46 "2021-12-12T15:38:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AlephNull](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@AlephNull](https://forum.obsidian.md/u/AlephNull)\
**Post date:** [January 14, 2022, 11:29am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/47 "2022-01-14T11:29:41Z")

</div>

+2!

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

Cheers!

---

<div class="post-metadata">

**Author:** ![DummyME](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@DummyME](https://forum.obsidian.md/u/DummyME)\
**Post date:** [January 14, 2022, 11:52am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/48 "2022-01-14T11:52:57Z")

</div>

+3  
For syncing frontmatter title.

---

<div class="post-metadata">

**Author:** ![rbanks88](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/r/4af34b/32.png) [@rbanks88](https://forum.obsidian.md/u/rbanks88)\
**Post date:** [February 11, 2022, 6:15pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/49 "2022-02-11T18:15:36Z")

</div>

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](https://forum.obsidian.md/uploads/default/original/3X/4/c/4cf216d0b0d70b96089852335e0291a5a45b2d50.png)  
But it’s still putting #Untitled at the end of the files.

What am I doing wrong?

Thanks,  
Russell

---

<div class="post-metadata">

**Author:** ![rbanks88](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/r/4af34b/32.png) [@rbanks88](https://forum.obsidian.md/u/rbanks88)\
**Post date:** [February 11, 2022, 7:29pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/50 "2022-02-11T19:29:15Z")

</div>

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

Am I dealing with the asterisk correctly?

---

<div class="post-metadata">

**Author:** ![sararkin](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@sararkin](https://forum.obsidian.md/u/sararkin)\
**Post date:** [February 12, 2022, 7:39am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/51 "2022-02-12T07:39:03Z")

</div>

> [@rbanks88](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![rbanks88](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/r/4af34b/32.png) [@rbanks88](https://forum.obsidian.md/u/rbanks88)\
**Post date:** [February 13, 2022, 6:54pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/52 "2022-02-13T18:54:11Z")

</div>

> [@sararkin](#):
>
> ._Bins/Templates._

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:

 ![2022-02-13-1143-55](https://forum.obsidian.md/uploads/default/original/3X/d/1/d1f1b64bb3fb58eb50e916e657bd4f6d050456a3.png)

And here’s the result:

 ![2022-02-13-1144-17](https://forum.obsidian.md/uploads/default/original/3X/4/f/4f1f9ff5e55e8a6e81788265465c0b5d4bc4cab4.png)

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

---

<div class="post-metadata">

**Author:** ![sararkin](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@sararkin](https://forum.obsidian.md/u/sararkin)\
**Post date:** [February 15, 2022, 3:03am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/53 "2022-02-15T03:03:37Z")

</div>

> [@rbanks88](#):
>
> Maybe it’s coming from some other plug-in? I’m just using the core Templates plug-in.

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

---

<div class="post-metadata">

**Author:** ![rbanks88](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/r/4af34b/32.png) [@rbanks88](https://forum.obsidian.md/u/rbanks88)\
**Post date:** [February 15, 2022, 2:28pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/54 "2022-02-15T14:28:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kenjibailly](https://forum.obsidian.md/user_avatar/forum.obsidian.md/kenjibailly/32/27360_2.png) [@kenjibailly](https://forum.obsidian.md/u/kenjibailly)\
**Post date:** [February 23, 2022, 10:00pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/55 "2022-02-23T22:00:53Z")

</div>

Thank you so much!

---

<div class="post-metadata">

**Author:** ![sararkin](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@sararkin](https://forum.obsidian.md/u/sararkin)\
**Post date:** [March 14, 2022, 8:10am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/56 "2022-03-14T08:10:10Z")

</div>

1.6 has been released which adds a option to disable the file-open event hook. Some people were reporting issues with templater because both plugins act on file-open. Disabling file-open for those cases should hopefully fix issues

---

<div class="post-metadata">

**Author:** ![Ooker](https://forum.obsidian.md/user_avatar/forum.obsidian.md/ooker/32/17469_2.png) [@Ooker](https://forum.obsidian.md/u/Ooker)\
**Post date:** [June 10, 2022, 5:42pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/57 "2022-06-10T17:42:18Z")

</div>

I suggest to have both options to whitelist/include and blacklist/exclude files, instead of having only the exclude option

---

<div class="post-metadata">

**Author:** ![freche](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/54ee81/32.png) [@freche](https://forum.obsidian.md/u/freche)\
**Post date:** [January 16, 2023, 10:51am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/58 "2023-01-16T10:51:13Z")

</div>

I have the title that changes twice in my files. Is there a new fonction of obsidian that does the same as filename heading sync now ?

---

<div class="post-metadata">

**Author:** ![sararkin](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@sararkin](https://forum.obsidian.md/u/sararkin)\
**Post date:** [January 17, 2023, 1:12pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/59 "2023-01-17T13:12:06Z")

</div>

Obsidian shows the file name above the current pane since 1.0. Depends on what you want - do you want the heading as part of the markdown document or are you okay with the obsidian display?

For myself, I turned off the Obsidian feature because I want all the information semantically in my files

---

<div class="post-metadata">

**Author:** ![MDbetter](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@MDbetter](https://forum.obsidian.md/u/MDbetter)\
**Post date:** [February 15, 2023, 6:36am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/60 "2023-02-15T06:36:50Z")

</div>

is it possible to set different level heading sync to filename, or just sync the first heading(no matter what level it is) to filename

[Previous page](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042.md?page=2)

[Next page](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042.md?page=4)
