Keep schema on content files up to date on Hugo based on archetype's?


I rely a lot my archtypes. As our platform (built on Hugo) grows, I’m finding it hard to keep my content files up to date with the new keys in my archetype.

Things I normally update my archetype’s with;

  • Hash comments: to define what a field was about
  • Empty quotes to define the main key
  • Default values for taxonomyies, event dates, etc that I shouldn’t be misspelling or forgetting :upside_down_face:

Is there a way to have Hugo run through the markdown files and automatically update the files with the newly defined keys and comments from my archetype?

Basically, look for anything that’s different from the source file, and add in the new fields. Don’t remove any field.

If I use something like Forestry, or Netlify CMS, it would solve this problem because they update your markdown file based on the YAML post type fields we newly add. We don’t want to integrate with a CMS in our stack because much faster for our teams to just work with archetypes.

No, there is not.

Even Forestry’s model isn’t all that smart about updates. From what I can tell your forestry archetypes tell the UI what fields to display. if there is an update if the field has the same name, it will overwrite. it will leave any “old data” that doesn’t match your field names.