Automatic Update of Frontmatter with Default Keys

I need to add a new key to the frontmatter:

newkey = true

Are there any utilities that allow you to automatically add this key to the frontmatter of all created pages with the value:

newkey = false

Is it possible to manage the values of all frontmatter to be able to delete or add new keys to all files? Maybe there is another way to do this.

My task: I need to add an information stream with the value “editor’s pick” to some files, so with this key, I can create a stream of files in a specific section of the page. Accordingly, I need to add a new key:

editor_picked = true

If this key is not present in other files, I will get an error. How can I solve this problem?

You may use tools like sed, perl, powershell to add stuff to your md files. Also some editors like vscode and notepad++ allow batch editing files.

For your use case coding defensive should do the trick.

In your page layout use

{{ if .Params.editor_picked }}
 This is picked
{{ else }}
  Normal page
{{ end }}
1 Like

As an option, I thought there might be a utility for correcting frontmatter. Something like a frontmatter migration (database) utility.

Regardless of manual or automatic editing…

It’s always good to code defensive and I think just adding the new key where you need it will be the simplest way to go

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