# 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:** 1

<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 27, 2021, 8:21am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/1 "2021-01-27T08:21:27Z")

</div>

Found myself always having the first heading of a file to be the same as the filename, so I wrote a little plugin to automate keeping them in sync.

![demo](https://forum.obsidian.md/uploads/default/original/2X/e/e90ddbc9bf676388e2df419cb5a8080f82b28daf.gif)

Github: [GitHub - dvcrn/obsidian-filename-heading-sync: Obisdian.md plugin to keep the filename and the first header of the file in sync · GitHub](https://github.com/dvcrn/obsidian-filename-heading-sync)

**Note:** This plugin will **overwrite** your existing heading and **rename** your file when you change that heading, so this can be considered _destructive_.

**Make sure you have a backup of your data**

---

<div class="post-metadata">

**Author:** ![Deinos](https://forum.obsidian.md/user_avatar/forum.obsidian.md/deinos/32/1301_2.png) [@Deinos](https://forum.obsidian.md/u/Deinos)\
**Post date:** [January 27, 2021, 7:09pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/2 "2021-01-27T19:09:48Z")

</div>

Sounds great! Just to clarify – it doesn’t rename files retroactively, does it? Only on active file? Do you plan to add it to the community plugins?

---

<div class="post-metadata">

**Author:** ![thoresson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/thoresson/32/534_2.png) [@thoresson](https://forum.obsidian.md/u/thoresson)\
**Post date:** [January 27, 2021, 8:53pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/3 "2021-01-27T20:53:23Z")

</div>

This solves a workflow issue for me! Does the H1 have to be on the first line, or will the plug-in find the first H1 regardless of which line it is on?

(Also curious about the backlink section. How do you do that?)

---

<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 27, 2021, 10:31pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/4 "2021-01-27T22:31:41Z")

</div>

> [@Deinos](#):
>
> Sounds great! Just to clarify – it doesn’t rename files retroactively, does it? Only on active file? Do you plan to add it to the community plugins?

It doesn’t rename retroactively, but when you open a file it will rename the first heading to the current filename. Probably should add a setting for that or some kind of way to identify which files it should run on and ignore existing files by default, hmmmm

It’s submitted to the community plugins 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 27, 2021, 10:33pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/5 "2021-01-27T22:33:41Z")

</div>

> [@thoresson](#):
>
> This solves a workflow issue for me! Does the H1 have to be on the first line, or will the plug-in find the first H1 regardless of which line it is on?

There’s a setting where you can adjust how many lines it should check. By default it’s 1 but you can change it up to 10 currently

In my tests on files that I never opened before, it ended up renaming the heading somewhere down the file so I prefer just the top.

> [@thoresson](#):
>
> (Also curious about the backlink section. How do you do that?)

That’s [Workflow runs · mrjackphil/obsidian-backlinks-in-document · GitHub](https://github.com/mrjackphil/obsidian-backlinks-in-document/actions)

---

<div class="post-metadata">

**Author:** ![pjeby](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pjeby/32/8080_2.png) [@pjeby](https://forum.obsidian.md/u/pjeby)\
**Post date:** [January 28, 2021, 2:52am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/6 "2021-01-28T02:52:48Z")

</div>

Before Obsidian, I used NotebooksApp, which names your files based on their first line of text… but _only_ if the filename it would generate for the current heading matched its existing filename when you opened it, or if the file was untitled to begin with.

It didn’t support front matter, alas. But this approach is nicely non-destructive since it effectvely only renames files that it named in the first place.

(Of course, my personal preference is to sync from header to filename, almost never the other way around.)

---

<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 28, 2021, 7:24am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/7 "2021-01-28T07:24:34Z")

</div>

Yeah the logic definitely needs some revamping to make it less destructive. Maybe some toggles in the settings, or commands you have to manually run to “start syncing”.

When you open a file, it doesn’t rewrite the filename, just the heading of that file. Only if you were to update that heading it would rename the file, but even for me it messed up some headings that I created before using this plugin 😇

I want to add some kind of tag to the file to mark it as “this is enabled for syncing” but don’t want to insert random stuff into documents

---

<div class="post-metadata">

**Author:** ![Thecookiemomma](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@Thecookiemomma](https://forum.obsidian.md/u/Thecookiemomma)\
**Post date:** [January 29, 2021, 2:01am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/8 "2021-01-29T02:01:52Z")

</div>

could we have a setting to exclude a Templates folder?

---

<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 29, 2021, 7:24am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/9 "2021-01-29T07:24:05Z")

</div>

If you have any good ideas how to handle exclusions (or inclusions) in a nice way, let me know and I’ll try to get it in.

Having a “excluded folder” setting doesn’t scale nicely and doesn’t fix the underlaying problem on what should happen when.

Maybe an “exclude this file” command? And save that into the state of this plugin. Although that could get big over a longer period of time.

---

<div class="post-metadata">

**Author:** ![Outis](https://forum.obsidian.md/user_avatar/forum.obsidian.md/outis/32/47537_2.png) [@Outis](https://forum.obsidian.md/u/Outis)\
**Post date:** [January 29, 2021, 2:24pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/10 "2021-01-29T14:24:16Z")

</div>

I asked about the availability of the plug-in in the Discord channel. Excellent work, btw.

Some people like myself prefer lower case filenames. A setting to lower case the filename perhaps?

---

<div class="post-metadata">

**Author:** ![icebear](https://forum.obsidian.md/user_avatar/forum.obsidian.md/icebear/32/2823_2.png) [@icebear](https://forum.obsidian.md/u/icebear)\
**Post date:** [February 3, 2021, 6:38pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/11 "2021-02-03T18:38:59Z")

</div>

Thanks, this looks useful

---

<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 5, 2021, 7:13am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/12 "2021-02-05T07:13:35Z")

</div>

This plugin is currently not updating backlinks yet. That’s a bug in obsidian is and being worked on according to some folks on the discord.

I also created [Vault.rename(file, path) is not updating existing links](https://forum.obsidian.md/t/vault-rename-file-path-is-not-updating-existing-links/12364)

---

<div class="post-metadata">

**Author:** ![Maury](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@Maury](https://forum.obsidian.md/u/Maury)\
**Post date:** [February 14, 2021, 7:49pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/13 "2021-02-14T19:49:39Z")

</div>

The plugin should insert the heading after the YAML frontmatter, if present.

---

<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 19, 2021, 4:23am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/14 "2021-02-19T04:23:19Z")

</div>

Released 1.1.0 with support for ignoring certain files through a new “ignore this file” command

 ![](https://forum.obsidian.md/uploads/default/original/2X/a/a99abedab0d3ee445a78bf17b8a69d9a79149871.png)

Also fixed the issue that links aren’t updated when renaming through this plugin

---

<div class="post-metadata">

**Author:** ![trydalch](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/t/73ab20/32.png) [@trydalch](https://forum.obsidian.md/u/trydalch)\
**Post date:** [February 22, 2021, 2:23am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/15 "2021-02-22T02:23:44Z")

</div>

It’s failing to install for me.

I had it installed previously, then it said there was an update. Tried to update, failed. Removed the plugin and attempted to install, but now it fails installation. So it seems something is wrong with the most recent release.

---

<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 23, 2021, 2:16am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/16 "2021-02-23T02:16:42Z")

</div>

Are you on the required version (0.11.0)? I just tried to reinstall it on a different machine (both update from 1.0 and remove → install) and had no issues here  
 ![Screen Shot 2021-02-23 at 11.15.14](https://forum.obsidian.md/uploads/default/original/2X/1/171364e3eabd15e4ec136ccfa633d68d451fda58.png)

---

<div class="post-metadata">

**Author:** ![trydalch](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/t/73ab20/32.png) [@trydalch](https://forum.obsidian.md/u/trydalch)\
**Post date:** [February 23, 2021, 3:12am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/17 "2021-02-23T03:12:32Z")

</div>

I thought automatic updates kept it updated, but turns out I needed to relaunch.

I now have it reinstalled. Thank you!

---

<div class="post-metadata">

**Author:** ![den](https://forum.obsidian.md/user_avatar/forum.obsidian.md/den/32/1932_2.png) [@den](https://forum.obsidian.md/u/den)\
**Post date:** [February 23, 2021, 3:55am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/18 "2021-02-23T03:55:11Z")

</div>

Can we just use some internal reference to file name?  
Some something like:

`## {file_name}`

- so it will just refers to file name
- when the filename is changed the header is change.

With this we don’t need plugin.

---

<div class="post-metadata">

**Author:** ![ben](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://forum.obsidian.md/u/ben)\
**Post date:** [March 7, 2021, 6:32pm UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/19 "2021-03-07T18:32:38Z")

</div>

Could this update the title in yaml frontmatter as well? That would be even more useful to me 🙂

---

<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 8, 2021, 2:03am UTC](https://forum.obsidian.md/t/plugin-for-keeping-the-filename-and-first-heading-of-a-file-in-sync/12042/20 "2021-03-08T02:03:24Z")

</div>

I don’t use frontmatter. How does this look like, can you post an example?  
Is this normalized and common, or more something specific to your setup?

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