Automatic/inline update of links to headers and blocks when they are modified (no extra dialog window)

I have found a workaround that I will be using from now on since Licat has formally stated the automatic update of links to headers will not be implemented.

I have a vault with many long notes in which there are headers and subheaders. I need the Number heading plug-in to help me navigate those notes.

I also use transclusions a lot. If it is just a paragraph I want to transclude, a block reference is sufficient; even for a header with 3-4 paragraphs it is doable to transclude each one separately so as to avoid linking to the header.

But when a header has more than 4 paragraphs it is not doable. So, then I would make my transclusion link to the header and all the paragraphs below until the next header (of equal level or 1 higher) will be shown. That is where the automatic update would be required.

Merging those paragraphs into 1 big block of text to not have to link to the header is not acceptable for readability in Live Preview and Reading mode.

So, here is what can be done: place a <br> between paragraphs, which effectively merges them into 1 block of text, but the <br>, which is not visible when not in focus (at least in my set-up), renders them as separate paras in LP and Reading mode.

You can then link to/transclude that one block of text, and that way a change in the header above will not break the link.

4 Likes

You can add a block reference to a heading (I just checked after reading your post). Itā€™s a little ugly because it takes on the heading formatting, but it is properly hidden in reading view.

1 Like

@CawlinTeffid if you use Reading mode a lot then that is fine, I guess. I am in LP all the time so I wonā€™t use that.

Another thing to bear in mind is that in the Outline pane that block ref will also show.

1 Like

This has to be added manually right? (you need to make a hex code or a human readable ID with the format ^... next to the heading)

If you have Plugin Creases installed it will hides the block ref at heading level (and also helps render Latex and Links) in the Outline pane. Itā€™s made by Liam Cain, now a team member, so I hope it will be incorporated into Obsidian one day. Would be a nice QoL improvement.

Iā€™m a noob, but can the implementation be like below?

  • Treat the Heading reference just like block reference (attaching a UUID to it. This make the UX consistent.
  • Have 2 embed syntaxes, one to embed only the heading, and the other to embed the heading with its content.
1 Like

If I have # Some header %^123abc% it shows up in the outline even with the Creases plug-in enabled.

So, how can I prevent the %^123abc% to show in the Outline pane?

Yes (they can also be added via templates).

Iā€™m probably missing out on something here, but I thought the block UUID on a header should have the format # Some header ^123abc?

With the Creases plugin the ^123abc will be hidden like below

I donā€™t understand the function of the 2 percentage signs % and why they need to be there?

Could you clarify this a bit? I was thinking of generating a UID for a random block and then cut and paste it to the Header. Not very elegant.

1 Like

For that you could make a date-based ID in a template, like ^{{date:YYYYMMDDHHmmss}}. You might be able to do something fancier using the Templater community plugin (which I havenā€™t used).

2 Likes

I looked at the Github ReadMe and thought that is what was needed. I obviously misunderstood.

You are absolutely right. Many thanks for pointing that out because that makes life a heck of a lot easier.

Wasnā€™t there another plug-in that generates those random 6-digit numbers with a caret in front automatically? I cannot for the life of me remeber which one it is. It is not the Templater.

Thereā€™s a Copy Block Link.
If you use it with a regular block (paragraph), itā€™ll generate the block ID and copy the block ref. However, with headings it doesnā€™t generate the block ID, and the block ref copied in clipboard is in Obsidian Heading reference format ([[Note name#Header]]). I guess Iā€™ll submit a feature request then.

1 Like

Got it, thanks a lot. You may be a noob, but you sure know whatā€™s going on a lot better than me whoā€™s been using Obs since May 2020!

Anyway, an FR is a possibility, but bear in mind there are something like 1600+ FRs already. This is not meant as a negative comment because not all FRs have the same weight; it is meant as realism.

As a workaround Iā€™ll follow your suggestion:

Once again, thanks a lot for your help and input.

1 Like

It is me again, sorry to bother you, but I wonder if I am on the wrong track again.

Letā€™s say in Note1 I have a header like this: # Some header ^f5e1lq.
If I then want to link to it from Note 2 like so [[Note1^f5e1lq]]
it will say that the note is not created yet, i.e. you cannot link to an ID number in a heading.

Am I right?

1 Like

When linking using the block ID, you need to follow the block reference syntax, which is [[Note name#^BlockID]]. Your syntax missed the hash sign #. Also, if you embed a heading using the block ID reference, the body content of the heading wonā€™t be embedded. We still have to use the Heading syntax here (which breaks if the heading is changed).

When I mentioned an FR above, I was talking about an FR for the Copy Block plugin to have a command to refer to a heading using block ID syntax. But then I ran into that issue above, that to embed the body content we still have to use the heading syntax. So thereā€™s no way to truly workaround the fact that Obsidian wonā€™t update the Heading reference link if you donā€™t remember to use the Rename Heading command. And Iā€™ll have to train myself to use the command every time I want to rename a header (The Block-reference-count plugin count should help?)

I so wanted to use the Number Headings Plugin but Iā€™ll have to stop now. Thereā€™s already an FR for the plugin to update links to heading, but I donā€™t have much hope that it can be implemented (it probably has the same constraints you mentioned above by the Obsidian devs) (Edit: lol I just read your comment from January saying that the dev said ā€œthe numbering NOT be part of the noteā€ couldnā€™t be implemented. Thanks for exploring this avenue so that I donā€™t have to.)

Youā€™re good! Youā€™re very active in the community and Iā€™ve benefited a lot from that (for example the CSS repository. Great contribution to the community and thank you so much!).

1 Like

I could shoot myself for this stupidity, of course I knew about the #. I use the Copy Block Link so you donā€™t get to type the syntax. Thanks for pointing it out.

Yes, the embedding issue remains, so using the Creases plug-in just to hide the ID in a heading that I donā€™t use so much is pointless.

At least we have cleared up everything now.

Thanks for your kind words. :grinning:

1 Like

When you rename a file, the links are automatically updated. This is the expected behavior for headings. I understand that this could be hard to implement but this is our unanimous feedback. Without this, renaming headers is feels broken. Right clicking on headings to rename headings is unnatural.

8 Likes

could this be done in YAML ?

How would that work?

in my YAML I have

created:
updated:

with the date format after

Barry

How would that allow Obsidian to keep track of changes to headers though?