Is it possible to inject/add front matter key/values using a hook for newly created markdown files (posts or custom collections)?
I am aware of the ability to add default header values using defaults in _config.yml file. However, this does not add those values to the actual front matter header and only allows access in liquid on the page variable.
The reason for this is because we have our pages structured like _pages/category/sub-category/file.md and we use cloud cannon for non technical users to edit/create content.
I’ve got a proof of concept working using File.write() within a hook but this triggers an infinite regenerate loop when running jekyll serve (I believe its because the file is written and the hook is triggered creating a loop).
I am using
Jekyll::Hooks.register :site, :post_read to achieve this. Can someone give me advice on how to accomplish this? Ultimately, we want a hook to run for newly created files and do some logic to add the yaml front matter headers for the file.