Red, not code red but text in the frontmatter and it is disturbing my demeanor / javascript & tp

What happened:

I added code to Frontmatter using Templater to ensure I put a title in. Because I am brain damaged.

It works, but it turned a lot of the matter red. What does that red mean? It is annoying and I can’t get rid of it.

Questions:
Is it a problem?
What do the colors mean?
Is the code written incorrectly even if it works?

Things I have tried

I’ve tried location. I have tried making it a field. I don’t know, that’s about it. I could split it into two templates, but do I want to execute two templates.

Is that the template view, or how a new file looks after running/inserting the template?

Template view. It run’s fine. I just don’t like red… or am wondering if it’s worth it.

You don’t need that Templater code inside the frontmatter area, what happens if you move it after the

---
frontmatter
---

section?

When viewing a template file you’re often not having a valid frontmatter, which is causing it to be red. So either you need to make it valid (which can be rather hard in some cases),or use a little bit of trickery.

The easiest way is to do this is to replace the first line with something like <% "---" %>, which in essence “disables” the frontmatter when viewed as a template file, but act normally after usage of the template.

That works as well! Thank you!

Thank you for taking the time. Both solutions work. Good times!