File being deleted after publish from Netlify CMS

Hi my Netlify site name is and github link is : GitHub - kalariyogi/kalariyogi-11ty-netlify-cms: Static site with eleventy and netlify cms
I am trying to update the config.yml to edit the index.njk file so I am using file collections. When I update the fields in Netlify CMS the file gets deleted.

Below is my config.yml file

name: git-gateway
branch: main

media_folder: “_site/images/uploads”
public_folder: “/images/uploads”

  - name: "posts"
    label: "Posts"
    folder: "posts"
    create: true
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
      - { label: "Layout", name: "layout", widget: "hidden", default: "layouts/post.njk" }
      - { label: "Title", name: "title", widget: "string" }
      - { label: "Description", name: "description", widget: "string" }
      - { label: "Date", name: "date", widget: "date", default: "" }
      - { label: "Post Body", name: "body", widget: "markdown" }
      - { label: "Featured Image", name: "featuredImage", widget: "image" }
  - name: "pages"
    label : "Pages"
      - label: "Home Page"
        name: "index"
        file: "index.njk"
          - { label: "Hero Text", name: "heroText", widget: "string" }
          - { label: "Hero Description", name: "heroDescription", widget: "string" }
          - { label: "Hero Image", name: "heroImage", widget: "image" }
          - { label: "Hero body", name: "body", widget: "markdown" }

Here is my index.njk file

layout: layouts/base.njk
permalink: /
heroText: Yoga
heroDescription: Yoga for the mind, body and soul
heroImage: none

<div class="jumbotron jumbotron-fluid" style="background-image: url("{{heroImage | url}}");">
  <div class="container">
    <h1 class="hero-text display-4">{{heroText}}</h1>
    <p class="lead">{{heroDescription}}</p>
<div class="container">
  {{ content | safe }}

Would really appreciate some help with this problem.

Nikhil Pereira

hi there, this was filed in the wrong area so it didn’t get the attention it needs! I have moved it, so hopefully someone has some input for you.

You can’t edit the frontmatter of a njk file and at the same time keep its html content, simply because the CMS only outputs data. It has no way of understanding or parsing anything other than data (yaml, json etc). I recommend you store the data in a separate file and load it in your index (instead of using frontmatter in the index). As you’re using eleventy, it’s probably easiest to use a json format (although you can configure yaml just as wel).