How to hide (empty) headers when they contain no contents below

What I’m trying to do

I’m using templates which include various headers and metadata. When the values in metadata are empty, they are automatically hidden in the reading mode. I want the same for headers. When the headers include no contents below them, I want them to be hidden in the reading mode.

image
=> You see no contents below the second and the fourth headers. I want them to be hidden.

Things I have tried

I see basically no related questions in the forum T-T please help me out

Do you expect for the headers to reappear if you enter some new metadata? If so, templates are not the correct tool. Then you should look into using simple dataview queries to output the header and associated values of the metadata.

Templates are (in most cases) used to do a one time setup at the creation time of a note.

Thanks for your reply.
Oh I think I misled you by bringing up metadata. Metadata has nothing to do with my question. I just made an analogy. Just like metadata is flexible in showing the values when the variables are entered and missing when they are not filled, I want the same function for the headers in the main text. As you see on the screenshot, there are four headers (each titled 1111, 2222, 3333, and 4444 respectively) and only the first and the 3rd headers include some contents below (that is, hello world), whereas the rest of the headers (i.e., 2nd and 4th) do not contain any contents. So, I want these headers (which do not have any meaningful contents below) to be hidden (or unseen) in the reading mode so that it looks much more neat than in the editing view.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.